I have been trying to write a batch file that removes files that are older than
x number of days. I have a backup directory
E:\Backup2 that contains a number of sub-folders
These sub-folders contain different internal structuring of files but I don't think this should affect the script as I only need it to look through every file in the
Backup2 directory, and if it is older than
x days then delete that file.
So far I have the following but I cannot get it to work:
FORFILES /P "E:\Backup2" /S /D -2 /C "CMD DEL /F /Q @PATH"
2 defines how old a file must be in days before it can be deleted.
When I execute the command in
CMD all of the files remain without any error being reported.
What is interesting however is that when I output to a log file, it reports the directory where the first file is located..
When I first ran the command the log file reported
E:\Backup2\Alfresco\25072015 however when I moved a log file to the root directory and re-ran the comman the log file reported
E:\Backup2 which suggests the command is finding the first log file it needs to delete and then breaks.