Detecting dates in foldernames

Hi,

I will name folders this way : DD-MM-YYYY (07-06-2011 for today).

DATE=`date +%d-%m-%Y`
mkdir $DATE

They will contain a backup of the day.

I want, in my backup script, add a command that will automatically delete folders that are a week old (in this case, when performing the backup of this day, this will delete the folder named 31-05-2011).
How do I do that ? Or, at least, how do I determine which folder is a week old ?
(Note that the folder names are not definitive and can be named the way it is easier to detect the date)

Thank you very much !

find command with mtime/ctime is a good option to look for instead of relying on file names!!!

Do search on forum you might get n number of thread :slight_smile:

sample one ...Delete user file(s) older then 'X' days ??

Thanks for your answers.

The reason why I want to rely on folder names is that if I delete folders by creation time, this will delete me other folders I don't want so !

# Need GNU date command
ODate=$(date -d " 1 week ago" +%d-%m-%Y)
rm -r $ODate

I'm running on FreeNAS, thus I don't have the GNU date command but your post makes me think I can download or install it, is this true ?

You can download from gnu.org, but remember it is included in package coreutils.

Coreutils - GNU core utilities

Well, I thought that would be easier, ie just a copy/paste of file x)
I have really no knowledge in linux, I just use FreeNAS on my server.

Can you help me ? Or just give me another method ? (I'm not sure it it possible to add so simply a command, is it ?)