I came across an interesting issue earlier today. Somehow, on my NTFS-formatted external hard disk I had managed to create a file system structure which was too deep.
Whenever I tried to delete a particular folder tree, I received strange errors about files which couldn’t be deleted:
Error Deleting File or Folder
Cannot delete foldername: The file name you specified is not valid or too long. Specify a different file name.
I thought that was strange – after all, I’d managed to create the files in the first place, then I found that if I drilled down to the files that would not delete, there was no right-click option to delete the file. Finally, I found that some folders displayed the following error when I tried to access them:
Can’t access this folder.
Path is too long.
It turned out that the problem folders/files had path names in excess of 255 characters. By renaming some of the top level folders to single character folder names (thus reducing the length of the path), I was able to access the problem files and folders, including deleting the files that I wanted to remove.
Damn good thinking! I never thought to rename the folders (my first inclination was to use DSL (Damn Small Linux), but your solution keeps me in Gate’s reach.
Thanks!
Thanks, I never thought of renaming the folders either.
There should be some shareware somewhere that will seek this out and let you fix it in advance. As said, maddening because you could create the path in the first place. I’d love to know all the paths on my hard drive which are ‘too long’ in advance. I think modern Windows conventions where “My Documents” is buried deep within other folders (c:\files and documents\users\admin\etc\etc\my documents) contributes to this.
Brillant Many Thanks Problem Fixed Grate Soultion
Brilliant, I had the same problem, eventually reformatted the external ntfs hard drive!! … and then read your solution after :~(
Don Thompson e-mailed me to let me know that the maximum path length depends on the method of access. It seems that UNC paths can be significantly longer than mapped drive paths.
Can only repeat. Damn good thinking.
Too cool. Thanks for the solution, saved a huge effort for me.
that link should be http://www.windowsitpro.com/Windows/Articles/ArticleID/44324/pg/2/2.html
you can paste it in the browser bar in bits!
helpful
Maybe robocopy could be used to generate an error report using the /256 switch, and presumably /ndl /nfl and nocopy switches? You can send the results to a file.
– worth a try, got the idea here:
http://www.windowsitpro.com/Windows/Articles/ArticleID/44324/pg/2/2.html
furthermore http://www.langa.com/newsletters/2005/2005-08-25.htm has an item, and links to http://www.herve-thouzard.com/modules/wfsection/article.php?articleid=1
helpful
There is a downloadable perl solution here, http://www.windowsitpro.com/WindowsScripting/Article/ArticleID/7828/7828.html
you can specify the threshold of pathname length above which you want a report
the zip file contains a small readme file but no massive explanantions
perl can be downloaded http://www.activestate.com (incl msi package)
helpful
I just used the 7828.pl file zipped in the download mentioned above:
works fine. I just opened the .pl file with a text editor and put my own paths in – it’s explained by the author anyway inside th .pl file.
My longest path was 231 characters and likely to expand (you know how it happens, someone creates a folder “fotherington-smythe’s archive sent by e-mail to Thomas, Thomas and Thomas on 30 February 2006”).
Now every path is back under 200 characters, and users have been alerted to what I only estimated previously.
p.s. Won’t robocopy copy everything anyway? Or move it with the /mov switch, or delete it by copying an empty folder to the top location of the part of the tree you want to erase and you using the /purge switch – you will then get a list of “extra” files and folders deleted below that location. or use the /mov switch to the NUL directory to delete stuff (I never got that one to work yet, but I have seen claims it does – i have no idea about syntax).
This is my lunchtime backup
AT 13:00 /every:M,T,W,Th,F C:\WINDOWS\system32\robocopy.exe \\server\share\ c:\backup\ /xf *.tmp /xf ~$*.* /s /e /zb /purge /nfl /ndl /log:c:\Logs\lunchtime.txt
it synchs a day’s work in minutes – I run it to a different network hard-drive each day to keep a weeks backups “right there”, uses hardly any bandwidth. I probably don’t need the /zb switch.
Helpful?
I had this exact problem while trying to back up files onto my Maxtor External hard drive. I was puzzled until today. I found a great app on Download.com called File and MP3 Renamer 2005
http://www.download.com/File-and-MP3-Renamer-2005/3000-2248_4-10482097.html?tag=lst-4-3
It lets you trim file names by a certain # of characters, or to a maximum length. And it can do them from the left or right side of the file name. It has many more ways of changing file names than that but I just went for the basic right-side file name trim.
The only thing it can’t do is find all files whose path names exceeds a certain length. Also, while the app can do hundreds or thousands of files at a time by trimming all files in a folder and its sub-folders, it does tend to crash if you do too many. So I couldn’t do my entire MyDocuments folder and all subfolders at once.
The only other quibble I would have is the interface is a bit unclear, namely that the buttons might say “Do this folder” and you might think that pressing it will choose that option, when in fact it then selects the OTHER option, that is, “Do this and all sub-folders at once”.
But it’s free for a 10-day trial and works great. I’m backing up my files right now with Retrospect without getting that uber-annoying “path name too long” message!
Thanks for that advise. Somehow, a seemingly endless nested directory structure was created of directories named “2003”. I am unsure how it even allows them to be created in the first place. My guess is that when files/directories are created, their blocks are allocated first, and then their name is placed in the file header, and then it is placed in its path within the filesystem. That seems like a possibility, at least.
Thanx, it’s really working
If you wish to avoid renaming folders (currently in use or you’re afraid of getting them back correctly), you can share a folder along the path and map that folder as a “remote” drive and then delete the file via the mapped drive letter path. Remember to remove sharing afterwards.
Wonderful, thanks for that. Took your advice and it solved my problem.
I had a script go wrong on me resulting in folders within folders within folders, etc.
After renaming the folders to single character names, I was able to dive deeper and deeper, ending up 71 folders deep. Most importantly, I was able to delete the string of empty and useless folders!
Thanks again. :-)
Just wrote this a week or so ago, might help some people:
http://groups.google.com/group/microsoft.public.windowsxp.general/browse_thread/thread/73cc6a8ca393b91f/167990fdf163250e?lnk=st&q=long+ntfs+path+utility&rnum=2#167990fdf163250e
feel free to repost any portions if they’re useful
Thanks greatly , this info solved me problem within a few file renames. CHAMP! Your info is great.
Thanks for the great lead on deleting filenames that are too long. Worked like a charm!
Brilliant, indeed! My original source parent folder was quite long, so I renamed that. Then I also realized that the target folder on the new server was named VERY long, without thinking about the long filename restrictions. So I also renamed that target folder to a single word. All data copied over just fine.
Thanks!
Sweet resolution!
good thinking……..
The foolowing 2 free tools may be of some use “to know all the paths on my hard drive which are ‘too long’ in advance” as suggested by post nr 3 in this thread:
=====
1)
=====
Long Filename Finder looks for file name length: http://www.dcsoft.com/products.htm
http://www.dcsoft.com/products.htm
=====
2)
=====
Even better: CutLongNames (http://www.replsoft.com/)
http://www.replsoft.com/cutlongnames.zip
This one allow you to search for total path plus filename lenght above a given value
Would need some improvement though:
– files with path lenght over 222 (excluding the file name) are displayed in red, and not clear why this threshold has been choosen (does not mach the OS limitaion)
– no progress bar while scanning (however I used It on a local HD 4 Gb folder in a few seconds)
– You need to press Edit button to see the detail of the path length and the filename length
– its quite easy to mix up between the search phase and the renaming phase (because the same button in used for both functions) ans I’m not very confident in the mass renaming function which has no undo feature (although there is a log in case you want to undo manually by yourself)
If someone around can find better, please post here.
I had the same issue. Yet the renaming technique didn’t work as the name was really long. Eventually I found the solution at http://winhlp.com/?q=node/39 “Cannot delete file or folder | Windows Problem Solver”
What worked for me was to use the DOS name, which is limited to 8+3 characters :
1. opening a command promt window,
2. finding the DOS name with DIR /X,
3. removing the folder using the RMDIR command followed by the DOS name.
HTH:)
Superb I had the Same Problem thanks to you I did not have to format my hard drive.Which was what I was going to do before I found this solution. Thank You ,Thank You , Thank You Very Much !!.
Just wanted to leave my thanks as well. This post saved me. Thank you!
I used the advice of a writer above and got a copy of robocopy. I deleted the directory by using the syntax: robocopy dummydirectory bad_directory /E /NOCOPY /PURGE . The dummydirectory was a temporary subdirectory that I created that had one small file in it. ROBOCOPY deleted thousands of subdirectories that had been created by a rogue program that was recursively creating new subdirectires.
It was the only probram or tool that could delete them as deep as they were. THANKS!
I’ve been using the following library that resolves the long filename & path issue. It is not free, but comes with samples and working code. It saved so much of my time!
http://www.abtollc.com/product1733992.html
There is no need to rename files or perform any other actions, it just allows to work with files keeping their real long paths, thats all.
Hey There
I had the same problem, had some users that should have moved their data files to some new servers.. but I couldn’t copy all the files because of long filenames..
I have just found a fine solution, that works.
To create a 100% copy of all the files, the users get the file as they have it now.. Use ntbackup, create a backup, move the backup file to the new server, and then restore the data to an alternate location, and thats it.
Worked for me :)
/kenneth
I just posted this blog entry.
http://kengers.blogspot.com/2008/02/ntfs-and-long-file-names-issues.html
Many thanks to Bob Coss for a free solution to this problem that actually works =)
Thanks a lot. I’ve been trying to delete a folder for about a month now. I used unlockers and everything. Didn’t know it was that easy. Thanks
Thanks!
After 3 days voo-doo-witchdoctoring-cmd-prompting and Googling tis was the solution… Thanx! You are my Guru!
great Solution
@ BOB COSS
Excelent advice on the robocopy command. I ran into this issue when using robocopy for file server backups/replication. The original file wasn’t too long, but the moved file was (longer folder path). I added that brilliant use of robocopy to my vbscript and now we have no issues programmatically deleting long file paths!!
Furthermore, I also have been struggling to find easy ways to delete systems files and files/folders that have been given very rescrictive permissions (1 user only and such). That command also works to remove files/folders you don’t have access to (I think system must have access – not real sure on that).
Thanks again to Bob for the command and to Mark for the site!
I faced the same problem, it was very useful to use different solutions before but due to Peter’s comment this one appeared to be the best for me http://www.abtollc.com/Products.aspx
Thanks so very much, Mark. Using your advice, I highlighted all of the files that wouldn’t delete. Then I renamed them all at once, using the letter a. Your suggestion worked like a charm. Thanks again; Largerick
Thanks alot for your idea. I have been trying it for few days and other advices found on internet are not as simple and brilliant as yours.
Hi, been reading this and it all seems very useful, but I am searching for long filenames on a citrix system. I’ve asked my IT dept to do this, but they cannot seem to so I thought I’d just research the net myself.
Can I ask which one of the tools/options mentioned in this forum is the best for just searching filenames that exceed the 255 length. I want to search what is known as our s: drive but don’t want to automatically rename stuff.
Thanks for your help on this
Thank you…thank you…thank you! So simple. I’d been going nuts trying to figure out what the issue was with some of my files. This saved me a LOT of work. Many thanks again!
Seth
THAAaaaaaaaaK YOU sOOOOOOOOO MUCH
Steff
The utility was updated not only to delete but also to copy files avoiding Path Too Long error. http://www.abtollc.com/Folder-Delete.aspx
Interestingly, a similar issue came up on the Windows 7 beta forums where Gordon Ryan made an interesting post:
Thanks a lot !!! Thanks so muchhh !!!!
Thanks to Bob Coss.
Robocopy got me into the mess i was in and it also got me out of it.
@ COSS… The robocopy solution is awesome! Thanks a million!
To All: I have been trying for 6 months to delete a file name “ZB” that came with a Canon software disk. You all gave me an answer. The renaming was what I needed, but Robocopy is a permanent addition to my collection. Thank you, ALL!.
This tool can delete/copy/rename long path files/folders
http://www.longpathtool.com
The old URL is for Unix only, the new utility optimized for PC is at: http://www.pathtoolong.com
( at least it run correctly for three months on my Windows XP )
I was googling about this problem, and you have solved my problems in a second. Thanks a lot
You can mount the path on your PC and change the file names
I had the same problem and then i sued a software called LongPathtool, it works fine.! i can highly recommend this tool to anyone.
http://longpathtool.com/Downloads.html
for solving this issue there is one simple method available please follow
1- please drag and drop the Folder that you wish to delete to a new folder or
C:\RECYCLER
2.then press shift+delete or normal delete
it should work …………….
Thanks for the information. Also try “Long Path Tool”. It helped me with Error 1320 in Win 7.:)
With Path too long error I use “Long Path Tool” to get fast and easy fix .
for All errors while these processes has been taken care by software named “DuplicateFilesDeleter”
You can also use Long Path Tool to sort out this problem.
I am using a software called Long Path Tool and it is working like charm, i have no problems in copying or extracting anything anywhere.
Try using Long Path Tool program this is very useful.
for solving this issue there is one simple method available please follow
1- please drag and drop the Folder that you wish to delete to a new folder or
C:\RECYCLER
Use Long path tool. It is really awesome one
i prefer to use software ( Long Path Tool )
Great to hear that “Long Path Tool” is working for so many people but it wasn’t an option when I wrote this back in 2005. Closing comments now…