Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi,
I need some help in writing this script which deletes ONLY SPECIFIC directories in a folder structure, which are 90 days old.
Directory structure is something like this:
1. Orders directory is having Incoming and Outgoing directories.
2. Each Incoming and Outgoing directories is having several Store1, Store2, Store3...dirs.
4. Store1 dir is having Today, Store1_20051007_093658, Store1_20060110_111149...dirs.
5. Similar with Store2,Store3...each will have Today, Store2__20060110_111149 dir under Store2...and Today, Store3_20060110_111149 dirs under Store3....This script has to delete only Store1_20051007_093658, Store2__20060110_111149...directories which has timestamp and which are 90 days old.
Orders, Incoming, Outgoing, Store1,Store2...dirs can be 90 days old and they should not be deleted.
I am doing something like this, but it's not working.
find /Orders/* -type d -mtime +90 |
grep -i [[:alnum:]]_[0-9]*Any help is highly appreciated.. Thanks, Siya

I just tried with this command and looks like it's working: Please let me know if you see a better way other than this:
find /Orders/* -type d -mtime +90 -name "*_*" -exec rm -rf {} \;

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |