0

There is a shared folder in my D drive as works (D:\works). I need to delete all the files in that folder and sub folders except word and excel files in there. how can i do this ?

Bishan
  • 15,211
  • 52
  • 164
  • 258

1 Answers1

1

You could do something similar to what this guy's done: http://www.codesingh.com/2009/08/using-robocopy-to-delete-old-files-from.html

Something like this should work:

mkdir D:\_tempDelete
robocopy D:\works D:\_tempDelete /e /MOVE /XF *.xls* *.doc*
rmdir D:\_tempDelete /s /q

Provided you have permissions to create and delete folders on D:. Otherwise you could just move the files somewhere on your local drive and delete them from there.

Kai G
  • 3,371
  • 3
  • 26
  • 30
  • what is `robocopy` ? not working in my computer. `'robocopy' is not recognized as an internal or external command, operable program or batch file.` – Bishan Feb 07 '12 at 08:15
  • 1
    It's standard in Vista and Win 7. Are you running XP? I think you can get it for XP - http://en.wikipedia.org/wiki/Robocopy – Kai G Feb 07 '12 at 08:30