bat script to delete file older than 7 days
- by Jessie
hi guys 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 am planning to have this bat file run by a windows scheduler task every day. My question is there a way to add into this cript 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"
)