I have a folder structure that is something like this:
C:\XYZ\
|---A\
|-----Archive
|---B\
|-----Archive
|---C\
|-----Archive
There are a total of about 150 folders. I run the command below to see what files are in the folders:
for /R C:\XYZ\ %i IN ("archive\*.*") do echo %i
I want to modify this command to delete all files in the archive folders older that a number of days. I tried the /d -20
somewhere in the command line to try and get the files just listed, but nothing seems to work.
Based on your requirement, following command will help you:
ForFiles /p "c:\XYZ" /s /d -20 /M Archive.* /c "cmd /c del @file"
For further help, please take reference from https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/forfiles
Note: Please backup your content before experimenting any command:D
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.