Discussion Locked

Purging Files X Days Old

0 helpful
4 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

In NT script, is there an easy way of deleting files with specific extension created more than X days ago?

In UNIX, I execute the following script to delete files '.trc' type which are older than 14 days:

find $DDB -name '*.trc' -mtime +14 -exec rm {} \;

Thank you.

4 replies

by msamson

try using pkzip (in the command line format)
www.pkware.com/shareware/pkzip_cli.html

pkzip25 -add -move -bef 100600 -dir=root test.zip *.goo

With this, you create a zip file with all the .goo files (they've been moved from their current location to the zip file) that were created before 100600 (10/06/2000)
All you have to do then is to delete the .zip file and you're done!!

Hope this helps!

Martin.

by farazid

This sloution must be placed in a .bat file so that it can be executed every day.
So, insted of 100600, I need something like (current_date - 14)

Is there such a thing?

Thank you!

by msamson

Just use the %cur_date% variable if you're looking for todays' files...

pkzip25 -add -bef %cur_date% -dir=root *.goo

by farazid

I do not want to delete today's files. I want to delete files 14 days old or older.

Thanks, Diana

This discussion is closed to new replies.