JSI Tip 9651. How can I delete a folder that returns PATH TOO LONG?

Jerold Schulman

August 18, 2005

1 Min Read
ITPro Today logo in a gray background | ITPro Today


When you attempt to delete a folder and receive PATH TOO LONG, you would normally Use the 8.3 short name, unless it has been disabled. Type dir /x . If the 8.3 path is too long, start renaming parent folders until the path is short enough.

I have scripted DelFolder.bat to delete a folder, even if the path is too long.

The syntax for using DelFolder.bat is:

DelFolder FolderPath

Where FolderPath is the path to the folder you wish to delete.

NOTE: DelFolder.bat uses RoboCopy.exe, which must be located in a folder that is in your PATH.

DelFolder.bat contains:

@echo offif {%1}=={} @echo Syntax: DelFolder FolderPath&goto :EOFif not exist %1 @echo Syntax: DelFolder FolderPath - %1 NOT found.&goto :EOFsetlocalset folder=%1set MT="%TEMP%DelFolder_%RANDOM%"MD %MT%RoboCopy %MT% %folder% /MIRRD /S /Q %MT%RD /S /Q %folder%endlocal



Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like