I created a batch file that just had the following command in it
forfiles -s -m *.log -d -30 -c "cmd /c del @path"
Now let me explain a little further. forfiles is an exe located on many versions of windows in the system32 directory by default, however, if it's not there you can download it and add it there from here: ftp://ftp.microsoft.com/ResKit/y2kfix/x86/
The *.log specifies to delete all log files from the folder, you could change this to be all files or whatever criteria you desire.
-30 says to remove anything older than 30 days
the section after -c is the command to run against the files
If the batch file is NOT run from the same directory as the files you are wanting to run this against you need the command to look like this:
forfiles
-p "C:\delete\these"
-s -m *.log -d -30 -c "cmd /c del @path"
Now just create a scheduled task to run this bat file on a routine basis and where good to go.
No comments:
Post a Comment