Delete Archive Files

December 22, 2010 at 14:41:54
Specs: Windows XP
To backup the data in my application, I run a nightly dump of each database to a text (SQL) file that is zipped and archived in a directory. I need to start cleaning these up because I'm running out of disk space with 5 databases and a year's worth of daily backups.

Ideally, I'd like to keep daily files for the last month plus 1 file per week before that. If possible, any data that's 6+ months old I would only keep 1 file per month, but that's optional.

For example, today is 12/22. I'd like to have daily files back through 11/22 (or 30 days if that's easier) plus the files from each previous Sunday. Anything from June or earlier I would only keep the last weekly backup file.

I have 1 directory per database, with the daily text files in it. I can run the process once per directory changing the directory name. The file names use the following convention:


Any idea how to accomplish this? Batch file, scheduled task, combination of the 2? Off the shelf software?

Let me know if I can provide any more info to clarify. Thanks in advance for your help.

See More: Delete Archive Files

Report •

December 24, 2010 at 12:10:34
are you familier with for loops ?
using for loop parase the date/month from [database]_[yy]_[mm]_[dd].zip and then using IF condition you can delete the files.
To calulate 30 days you can use calulation of SET and for loop.

Or let us know if it seems bouncer. We will try to wrtie a code .

Subhash Chandra.

Report •

December 27, 2010 at 08:11:48
I'm a novice at batch files. I don't know how to implement For loops or parse filenames in them. Any code that you could supply to do this would be appreciated.


Report •

Related Solutions

Ask Question