I have a bat script in which gets all files in a folder and then converts this folder with its contents into a one RAR file. This script also adds the current date once it makes a copy and moves it this file into a backup folder. I’m planning to have this bat file run by a windows scheduler task every day.
My question:
Is there a way to add into this script to also delete all rar files older than 7 days in the backup folder?
for /f "delims==" %%D in ('DIR D:\scripts /A /B /S') do (
"C:\Program Files\WinRAR\WinRAR.EXE" a -agyyyy-MM-dd -r "c:\backup\scripts.rar" "%%D"
)
It just so happens…
I have a very similar script (Visual Basic Script) that does this. However you will need to modify the directory path, file extension (.RAR) and date length (in this example its >=3 set this to 7):
EDIT 1:
Simply copy & paste this into a new textfile and rename the extension as .vbs.
Sample Solution Script:
I hope that helps.