1.

Solve : Batch file to periodically delete certain files?

Answer»

Hi, I need to MAKE a batch file that will delete all of the *.log files in a particular directory every 10 days, but I'm not having much luck. I was thinking of writing a flag file and then everytime the user starts this program the batch file is launched and COMPARES the current system date to the flag file's last modified date and if it's 10 days or more difference, DELETES all of the log files and makes a change to the flag file (to update it's last modified date). Any batch-gurus know of a way to do this?this would wurk?:

Code: [Select]DEL filename.log
Your idea of a flag file is very good. Batch language is rather limited but depending on your OS this could be done. Another option would be Windows Script which has many date functions WELL suited for aging files.

Also, you could USE the task scheduler.

the batch file:

@echo off
del path\*.log

When you schedule the job, on the schedule tab, set the time to run, and set 'schedule task' to daily. Then set the 'every' box to 10.

Hope this helps.



Discussion

No Comment Found