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