Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

batch file to zip old files

Status
Not open for further replies.

De8o

Technical User
Sep 26, 2000
70
US
Can anybody suggest a batch file that will zip *.dat files in directory that are older than 2 days [sig][/sig]
 
I don't know of a way to do it individually with a batch file, although it would not be a big deal to write a quickie VB app to do it. The zip command for doing OLDER files is:

pkzip -T10212000 -m old.zip *.dat

where -T10212000 means "take all files older than [date]"
and -m moves the files to the archive. Bad news: it puts them all into one archive.

I really would do it in VB. The easiest way i see is to output the directory to a text file (dir >dir.txt) then parse the text file for filenames and dates older than 2 days. Let me know if you want to do it this way, I can probably put together some quickie code for you if you need it.

David Moore
[sig][/sig]
 
Thanks David, but I actually got it sorted. I did want the files to be stored in one zip file. I found a file called oldfiles.exe which allows you to move files older than x days. I then zip them with winzip 8 through the command line and then delete the files in the temp folder.
Again, much thanks for the offer of writing code,
Darren [sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top