New Snippet New Snippet Recent Snippets Recent Snippets My Snippets My Snippets Web Code Search Snippets Search
Sign inor Register
Language: NoFormat

Delete all folder contents except one folder

51 Views
Copy Code Show/Hide Line Numbers
rem Replace {folder} with the folder whose content you want to delete
rem Replace {folderToKeep} with the folder under {folder} you DON'T want to delete
del /F /Q {folder}\*.*
for /D %i in ({folder}\*.*) do if /I NOT (%i)==({folder}\{folderToKeep}) rd /s /q %i
by Al Gonzalez
  February 12, 2010 @ 8:05am

Add a comment


Report Abuse
brought to you by:
West Wind Techologies


If you find this site useful and use it frequently please consider making a donation to support this free service.
Donate