Link to home
Start Free TrialLog in
Avatar of Alan OBrien
Alan OBrienFlag for Ireland

asked on

FORFILES doesn't seem to delete files in folder

Hi All,

I have a forfiles batch which i run on a server to delete files older than 21 days in a network folder. The script completes ok but the files dont seem to delete.

forfiles /p "Z:\servername" /d -21 /c "cmd /c echo y> del @path

What am i missing?

Avatar of Meir Rivkin
Meir Rivkin
Flag of Israel image

it seems u forgot a double quote, you have one before cmd but where's the closing one?
forfiles /p "Z:\servername" /d -21 /c "cmd /c echo y> del @path"

Open in new window

you may also want /S to go down into subdirectories
Avatar of Alan OBrien


Thanks Segwick, i had just copied and pasted from the batch and didnt copy the double quote but i had it in there already
Avatar of Qlemo
Flag of Germany image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Will try those out and let you know tomorrow. thanks.