'Batch script To delete a folder in a group of folders depending on a specified folder name
For example I have:
path- E:\what\ever
files in that path- logs_05-18-22
logs_05-11-22
logs_05-4-22
I have a batch script that is creating a new logs_***** folder every week. What I'm trying to do is to simultaneously have a command that deletes the 3rd folder in the group (aka the oldest file), so in this example folder logs_05-4-22 would need to be deleted as logs_05-26-22 is being created. The week after that when logs_06-2-22 is created folder logs_05-11-22 will need to be deleted.
What I tried but was getting a ERROR: Invalid argument/option - '@file' forfiles /p "E:\what\ever" /s /d -3 /c "cmd /c del @path forfiles /p "E:\what\ever" /s /d -3 /c "cmd /c del @file : date>= 3 days >NUL
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
