Skip to main content

Posts

Showing posts from August, 2011

How to delete folders when PATH is too long?

Use Robocopy, or "Robust File Copy" This is a command-line directory replication command. It has been available as part of the Windows Resource Kit starting with Windows NT 4.0, and was introduced as a standard feature of Windows Vista, Windows 7 and Windows Server 2008. Robocopy can be downloaded from http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=17657 The following batch file can do the job. Keep the batch file in your path. DelFolder.bat @echo off if {%1}=={} @echo Syntax: DelFolder FolderPath&goto :EOF if not exist %1 @echo Syntax: DelFolder FolderPath - %1 NOT found.&goto :EOF setlocal set folder=%1 set MT="%TEMP%\DelFolder_%RANDOM%" MD %MT% RoboCopy %MT% %folder% /MIR RD /S /Q %MT% RD /S /Q %folder% endlocal