Delete a folder with file xy.z that is older then X days

48 Views Asked by At

I want to delete all folders with an old file. I try to solve it with forfiles to find my old files and remove the whole folder. The problem i get is, when i found the file forfiles is in the folder what i want to delete and i get the "acess denied, is being used by another process" error.

forfiles /p "C:\Users\abc\Desktop\tmp\test" /s /m xy.z /d -1 /C "cmd /V:on /C  if @isdir==FALSE set tmpPath=@path&set tmpPath=!tmpPath:xy.z=!&cmd /c rd /s /q %tmpPath% "
0

There are 0 best solutions below