I am looking for a way to use robocopy to rotate log files. Currently I have a batch file using robocopy to copy files and log the results to a specified folder location. What I would like to do is keep 7 days and on the 8th day drop one off. Is this possible or should I create another batch file to do this and call it from the original batch file?
|
feedback
|
|
If you are using a batch file, then it can delete older files in the log-files directory. Here are two references: ForFiles - delete old files, etc. batch file to delete files older than a specified date | |||||
feedback
|
|
You could use the following script:
| ||||
|
feedback
|
|
You could do something like this. Bit ugly, but it works. No real reason to use robocopy, as opposed to just a straight copy. This assumes your logfile is in a standard place, of course.
....
| |||
|
feedback
|