Question : Batch file for deleting old files more that xx days.

Hi Experts,

I required a batch file which runs automatically and move old file more than 10 days to archive folder and then delete after 30 days from the archive.

Thanks
Sobitharaj.S

Answer : Batch file for deleting old files more that xx days.

This sounds like a job for ROBOCOPY to me.  You can do this easily with just two lines using it.  Something like:

@echo off
set BaseDir=c:\in
set SaveDir=d:\archived
set TempDir=d:\_delete
robocopy "%BaseDir%" "%SaveDir%" /minage:4
robocopy "%SaveDir%" "%TempDir%" /move /minage:15
rmdir /q /s "%TempDir%"

If you don't have a copy of ROBOCOPY it is available as part of this download:

http://technet.microsoft.com/en-us/magazine/2006.11.utilityspotlight.aspx

There are other useful command line options you might want to explore, here is some additional info:

http://technet.microsoft.com/en-us/library/cc733145%28WS.10%29.aspx
http://ss64.com/nt/robocopy.html

~bp
Random Solutions  
 
programming4us programming4us