1.

Solve : Delete aged files from batch, .bat, file?

Answer»

I've done a COUPLE searches in the DOS forum and promise I didn't find exactly the answer. So I apologize if this has been covered.

I want to create a bat file that will delete AGED files with certain prefix. Then I can call it from a scheduled task, say, every day.

I was trying the DEL function but can't find a way to utilize a date... below works so far, just that it deletes all the TT files:

DEL /S \\SERVER\TestDelete\Temp\TT*


Any thoughts appreciated, thx.

I don't KNOW how to do it using standard Command Prompt commands, but I made a console app to do it for me. I'd be happy to share it if you have no other alternative, I know it's a little scary using a program that does such a thing from someone you don't know :-/

The program works like this:

DeleteFileByAge "c:\temp\*.log" 30

That entry deletes all the .log files from the c:\temp directory that are more than 30 days OLD. I have an entry in Windows Scheduler to run the SCRIPT at midnight.



Discussion

No Comment Found