问题
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 ?
回答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.
来源:https://stackoverflow.com/questions/9170560/delete-files-with-windows-command-prompt