PC Review


Closed Thread
Thread Tools Rate Thread

Can't delete folders where PATH is too long

 
 
Jeff T
Guest
Posts: n/a
 
      1st Jul 2003
OS: Windows XP Pro

I have a client who somehow got a ba-zillion folders created and now
can't delete them. I've read the Q articles Q180410 and Q157069 but
two methods described don't work because at the end of this path is a
set of folders that *does* have data. So I guess it's like the old
deltree command where you couldn't delete a folder unless it was
empty.

It's alright that the data be deleted as it is backed up but does
anyone know how to delete the long path even though there is data in
some of the outlying folders?

These two techniques do not work:

~ share the folder, then map a drive and delete from the mapped drive
letter.

~use the subst command to create a virtual drive and delete from
Windows explorer all folders underneath.

In the first solution, the drive won't map as Windows can't access the
outlying folders beyond 255 characters.

In the second solution a drive letter *is* created but you can't
delete any folder as Windows reports there is inaccessible data.

Is there another solution for removing these folders and data?

thanks

Jeff
 
 
 
 
 
Patty S.
Guest
Posts: n/a
 
      1st Jul 2003
Have you tried rd /s?

Patty S.

"Jeff T" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> OS: Windows XP Pro
>
> I have a client who somehow got a ba-zillion folders created and now
> can't delete them. I've read the Q articles Q180410 and Q157069 but
> two methods described don't work because at the end of this path is a
> set of folders that *does* have data. So I guess it's like the old
> deltree command where you couldn't delete a folder unless it was
> empty.
>
> It's alright that the data be deleted as it is backed up but does
> anyone know how to delete the long path even though there is data in
> some of the outlying folders?
>
> These two techniques do not work:
>
> ~ share the folder, then map a drive and delete from the mapped drive
> letter.
>
> ~use the subst command to create a virtual drive and delete from
> Windows explorer all folders underneath.
>
> In the first solution, the drive won't map as Windows can't access the
> outlying folders beyond 255 characters.
>
> In the second solution a drive letter *is* created but you can't
> delete any folder as Windows reports there is inaccessible data.
>
> Is there another solution for removing these folders and data?
>
> thanks
>
> Jeff



 
 
Jeff T
Guest
Posts: n/a
 
      8th Jul 2003
Patty,

how would you go about using this command? i.e. from which folder, the
parent or further in? From a command shell within XP?

thank you
Jeff


On Tue, 1 Jul 2003 11:01:00 -0700, "Patty S."
<(E-Mail Removed)> wrote:

>Have you tried rd /s?


 
 
New Member
Join Date: May 2007
Posts: 1
 
      8th May 2007
Just wanted to let you know I had the same problem--could not delete from command line, because directory structure had somehow become too deep (Hey nice job Microsoft, thanks for letting me create a directory structure that is too long to be managed by Windows--maybe you should prevent this from happening in the first place!).

Anyway, using the remove directory command with subdirectory switch did the job:
rd /s nameOfDirectory

Best and kind regards
 
 
New Member
Join Date: Aug 2008
Posts: 1
 
      25th Aug 2008
Has anyone tried the abtollc site? It sounds like quite a useful patch, but noscript blocks the site entirely, and I wonder if I should disable the blocking?
 
 
New Member
Join Date: Mar 2009
Posts: 1
 
      14th Mar 2009
Don't bother with that abtollc site, it's pretty worthless to pay for something you can do for free.

Windows IT Pro has a good article and a batch file you can use that will fix this issue for you.

http://windowsitpro.com/article/arti...-too-long.html

Basically it uses RoboCopy and you use a Batch file and it removes all the folders for you. I had a folder that was nested several thousands folders in (because of a copy issue I had). Creating the DelFolder.bat file worked great and fixed it in about 30 seconds (it had to delete a TON of nested folders/files).

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 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

Last edited by SolutionFinder2; 14th Mar 2009 at 05:52 PM..
 
 
New Member
Join Date: Mar 2009
Posts: 1
 
      22nd Mar 2009
OSMstudios makes a handy little Java utility to take care of this problem.

http://www.osmstudios.com/Display.asp?Page=pathtoolong
 
 
New Member
Join Date: May 2009
Posts: 1
 
      26th May 2009
I tried the bat file but I get errors saying that it cant find the directory but it IS there!

I also get errors saying that directories aren't empty.. sigh.. will i have to manually empty all dirs? Eclipse made this problem for me
 
 
New Member
Join Date: Aug 2009
Posts: 2
 
      16th Aug 2009
This cmd script works for me:

Code:
@echo off
  if _%1_==__ (
  echo Usage: %0 folderpath
  goto end
  )
  
  setlocal
  
  set i=%2
  if _%i%_==__ set i=0
  set /A i=%i% + 1
  
  del /Q /F %1\*
  
  for /D %%d in (%1\*) do (
  move %%d %i%_%%~nd
  )
  rd /Q %1
  
  for /D %%d in (%i%_*) do (
  call %0 %%d %i%
  )
  
endlocal
    
:end
 
 
New Member
Join Date: Aug 2009
Posts: 2
 
      17th Aug 2009
Slightly refined:
Code:
@echo off

if _%1_==__ (
echo.
echo Usage: %0 folderpath
echo Deletes specified folder and all subfolders, even if the path depth
echo is larger than what CMD/Explorer will manage.
echo   folderpath - the folder to delete
echo.
goto end
)
 
setlocal

rem ** The full path of the folder to delete
set target_folder="%~f1"
set target_drive=%~d1

rem ** Create a temp folder on the same drive as the target folder (since moves within the same drive does not involve copying and traversing paths)
set tmp=%3
set del_temp_folder=nope
if {%tmp%}=={} set tmp=%target_drive%\temp_%RANDOM%
if not exist %tmp% (
md %tmp%
echo Will delete folder: %target_folder%
echo Will use temp folder: %tmp%
set del_temp_folder=yepp
pause
)

rem ** Create a prefix to use on moved folders to avoid name clashes
set i=%2
if {%i%}=={} set i=0
set /A i=%i% + 1

echo Level %i%, folder %target_folder%

rem ** Delete all files (non-directories) from the folder
del /Q /F %target_folder%\*

rem ** Move all subfolders to the tempfolder, and delete the now empty folder
for /D %%d in (%target_folder%\*) do (
move "%%d" "%tmp%\%i%_%%~nd"
)
rd /Q %target_folder%
 
rem ** Recursively repeat the above for all the moved subfolders
for /D %%d in (%tmp%\%i%_*) do (
call %0 "%%d" %i% %tmp%
)

rem ** Clean upp
if {%del_temp_folder%}=={yepp} (
rd /Q %tmp%
)

endlocal

:end
 
 
 
 
Closed Thread

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
http://LongPathTool.com - copy and delete path too long filesWindows tool to copy or delete files and folders with path too long orfilename too long error. Just browse to the file and press a button to copyor detele it, thats it! The applicati Martin Krag Windows XP MovieMaker 0 24th Apr 2011 01:27 PM
http://LongPathTool.com - find and delete/copy path too long filesfrom your hard drive or LAN Windows tool to copy or delete files and folderswith path too long or filename too long error. Just browse to the file andpress a button to copy or d Martin Krag Windows XP Networking 0 22nd Apr 2011 11:07 AM
http://LongPathTool.com - find and delete/copy path too long filesfrom your hard drive or LAN Windows tool to copy or delete files and folderswith path too long or filename too long error. Just browse to the file andpress a button to copy or d Martin Krag Windows XP Setup 0 22nd Apr 2011 11:06 AM
http://LongPathTool.com - find and delete/copy path too long filesfrom your hard drive or LAN Windows tool to copy or delete files and folderswith path too long or filename too long error. Just browse to the file andpress a button to copy or d Martin Krag Windows XP Configuration 0 22nd Apr 2011 11:05 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:11 AM.