Delete a folder with too many characters in its path.
If you want to delete a folder and it gives you the error message: ‘Path is too long’, you can simply keep digging into the folder untill you find a point where it doesn’t give you the error anymore, or you can create a batch file containing the following text:
@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
This script uses RoboCopy, which is included in the Microsoft Windows Server 2003 Resource Kit and can be downloaded here. It is included in Windows 7.
command line, microsoft, windows
I had this problem and searched many threads but my dev gave me a easy (for me) solution ( he did all the research ).
install Cygwin
cd to the folder with the files you want to delete. I want to delete everything in longpathfile has a file named runs I want to delete:
$ cd longpathfile/
rm -rf runs/
True, it can be solved using Cygwin. Cygwin creates a linux-like environment on your windows machine. It’s quite a bloated installation for just solving this problem IMHO.
But nevertheless it works, and when you work in a mixed windows-linux environment it sure brings a couple of extra advantages.
Thnxs for your input.