Recursive delete on Windows

I spent a stupid amount of time writing a batch script for something 10 minutes later I found out I could accomplish with one line.

Dreamweaver creates files called dwsync.xml inside every directory you syncronize after your first sync and I wanted to delete them all.

My batch file wasn’t too crazy, but the spaces in the file path caused some uglyness.

Anyway, the command to do this, once you’re in the highest directory you want to delete from is:

del /AH /S dwsync.xml

The hardest thing about figuring this out, is that in Windows, even a command prompt (even an Administrator command prompt) hides hidden files — so you need the /AH switch.

You could also add a prompt for each file, which is what I did for the first few to make sure everything was working as expected with the /P switch.

Posted Saturday, August 14th, 2010 under tips and tricks, windows.

Leave a Reply