I wanna use forfiles to delete files older than 92 days, but the code seems to be breaking. I have a dynamic folder name.
for /d %X in (e:\local\test\backups\s?????pbx\) do forfiles /p %X /m *.cab /c "cmd /c del @path" /d -92
I couldn't figure out where I am going wrong. Is there any other way to achieve this? Any help would be appreciated.
Windows commands only support wildcards in the terminal node of a path - It will not find paths that appear anywhere before the last \\
.
The solution for your problem is really simple :-) Just remove the final \\
for /d %X in (e:\local\test\backups\s?????pbx) do forfiles /p %X /m *.cab /c "cmd /c del @path" /d -92
Batch uses *
as a wildcard character. Try this:
for /d %X in (e:\local\test\backups\s*pbx\) do forfiles /p %X /m *.cab /c "cmd /c del @path" /d -92
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.