1.

Solve : how i can delete old files ??

Answer»

hello
i have backup directory  (d:\SQL-Backup\.)

and i wanna delete 7-15-30-60 days ago "rar" files  (base is file created day.. because.... sql backup STARTING everyday 22pm and backup WORKING everyday)

why different time ? have multi diffrent program backup directory and this batch will work different time line

could you help me ?

thxI think the easiest way would be to use forfiles.

Code: [Select]set agefactor=7

forfiles /p d:\SQL-Backup /s /d -%agefactor% /m *.rar ^
/c "cmd /c echo PATH older than %agefactor% days"

I prefer not to WRITE destructive code, so as written the snippet will just list the files. You can change the echo COMMAND to a del command once you are satisfied with the results. Also change the value of agefactor in the first line as needed. Note: Enter the agefactor as a positive number, it will be converted to a negative number in the code.

Good luck



Discussion

No Comment Found