Avatar of Alan OBrien
Alan OBrien
Flag 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?

Windows Server 2003Windows BatchScripting Languages

Avatar of undefined
Last Comment
Alan OBrien

8/22/2022 - Mon
Meir Rivkin

it seems u forgot a double quote, you have one before cmd but where's the closing one?
Meir Rivkin

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
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
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

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Alan OBrien

Will try those out and let you know tomorrow. thanks.