Sometimes it is required to delete old backup files and leave only new ones. I never had problems with this on Linux using command find with -exec option, but in case of Windows I had to do some research. As a result the following string will delete all zip files older than 20 days on G drive. I insert this command into a batch file which creates zip backups.
forfiles /P G:\ /S /M *.zip /D -20 /C "cmd /c del @path"
This example is for modern versions of Windows, such as Windows 7 or Windows 2008 Server, but what about Windows XP? Here is the working example for it:
forfiles -pe:\ -m*.zip -d-20 -c"CMD /C DEL @FILE"
forfiles /P G:\ /S /M *.zip /D -20 /C "cmd /c del @path"
This example is for modern versions of Windows, such as Windows 7 or Windows 2008 Server, but what about Windows XP? Here is the working example for it:
forfiles -pe:\ -m*.zip -d-20 -c"CMD /C DEL @FILE"
No comments:
Post a Comment