Cannot delete file: filename too long
Sometime ago, I made a copy of a hierarchy of folders under my "Users" folder to another drive as a quick backup. I no longer need this copy of folders and files. So when I tried to delete these files I got a message that some filenames are too long. When I look at these files they mostly seem to be part of Internet Explorer temp directory, and also some files used by Mozilla Thunderbird, so they were likely created by these utilities on purpose. I cannot rename them to shorter names, or even move them to lower folders. I can't even copy their filenames to show you what these filenames are! When I use the DOS prompt's "dir /x" command these files do not even have any 8.3 short filenames either, which I could've used to delete them with. There are over 400 of these files! I know what the problem is, the Windows OS has a limit of somewhere around 250 characters for filenames and complete pathnames. I've seen some utilities advertised saying that they can delete these files, but they all require money. Anything that's free?Yousuf Khan
May 14th, 2011 12:45am

Hi, How about holding Shift + Delete? Google for MoveOnBoot. MoveOnBoot will only removes files and not directories though. Best Regards, L.S
Free Windows Admin Tool Kit Click here and download it now
May 16th, 2011 11:31pm

Hi, How about holding Shift + Delete? Google for MoveOnBoot. MoveOnBoot will only removes files and not directories though. Best Regards, L.S Why is shift-delete different?Yousuf Khan
May 17th, 2011 12:51am

Hi, It is just for testing. It is good since the files can be deleted in Linux. However, if you don't have Linux, it needs to find the way to delete the files under Windows. Since the files are located in Internet Explorer temp directory, you could use Disk Cleanup to clear the Temporary Internet Files. Also, check if the following KB is helpful. It has several methods. Go to check if 8.3 name creation is disabled. http://support.microsoft.com/default.aspx?scid=kb;en-us;320081 Best Regards, L.S
Free Windows Admin Tool Kit Click here and download it now
May 17th, 2011 6:02am

Hi, It is just for testing. It is good since the files can be deleted in Linux. However, if you don't have Linux, it needs to find the way to delete the files under Windows. Since the files are located in Internet Explorer temp directory, you could use Disk Cleanup to clear the Temporary Internet Files. Also, check if the following KB is helpful. It has several methods. Go to check if 8.3 name creation is disabled. http://support.microsoft.com/default.aspx?scid=kb;en-us;320081 Best Regards, L.S Regarding it being in the Internet Explorer temp directory, it actually wasn't. Remember I said in the original posting that this was in a backup directory of these directories, so Disk Cleanup has no way of knowing that this belongs to Internet Explorer or anything else. Also there was a Thunderbird directory having the same issues as well, which Disk Cleanup wouldn't have touched no matter what. Okay, I checked out the state of the filesystem registry. The "NtfsDisable8dot3NameCreation" entry in the "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem" is set to non-zero, meaning the feature is in effect. Interestingly it was set to 2 rather than 1, but I doubt that makes a difference. Even if I disable this feature right now, all previously created files still won't be assigned the 8.3 filenames, just only those files that are newly created will have the 8.3 filenames available.Yousuf Khan
May 18th, 2011 8:57pm

I had a similar problem with file name "too long" on Win XP. With code that walked through every directory tree and making changes to each file and the new saved to a different location. All was fine until a saved location was specified as sub directory under the source directory. It recursively made empty sub directories, ~2800. After searching for several hours and trying everything mentioned could not delete them. Even after opening the dual boot to Ubuntu 11.04 and accessing that directory under "host" it could not delete the directory. I had to write some code to walk the directory and after so many then rename the next which "moved" all subsequent subs, which didn't actually move anything on the hard drive but just the index of where it is at, like the FAT table or however that is done in NTSF. Then the few that were left in the source directory could be deleted. I had to tinker with the number left so it was not "too long" and throw the same error. That had to be done over and over until they could all be deleted.
Free Windows Admin Tool Kit Click here and download it now
June 16th, 2011 7:55am

I would have tried to emacs the directory and pressed 'd' and I think 'x' to expunge. Or use the cygwin unix commands for windows.
June 16th, 2011 1:55pm

For future reference, the trick is to substitute a drive letter for the parent path, thus making the total path less than the 250-odd character limit. e.g. For file in "C:\a\very\long\path\You cannot delete me.txt" do: subst x: "C:\a\very\long\path" del "x:You cannot delete me.txt" subst x: /d There is a Microsoft KB article about deleting stubborn files, which suggests adding the Windows internal path prefix of "\\?\" to the path (e.g. "\\?\c:\a\very\long\path") which has no limit, but unfortunately doesn't work at the command line. The path prefix is commonly used by device drivers internally to register their devices' physical path or to reference drive letter agnostic paths, e.g. with the volume GUID at the start instead of a letter. It has been supported in every version of Windows since Windows NT. I know that because I wrote a File System service driver compatible with NT and 2000 some twelve years ago now 8-)
Free Windows Admin Tool Kit Click here and download it now
May 20th, 2012 9:04pm

You probably cannot rename the last file because it's path is teh end of the string that is too long, but you should be able to rename the folders in between, starting at the root. Once renamed, you will shorten the whole path length, and you will be able to delete the folder tree.Geoff Courts, Operations Manager, Macnamara IT www.macnamara.it
May 29th, 2012 4:17am

You probably cannot rename the last file because it's path is teh end of the string that is too long, but you should be able to rename the folders in between, starting at the root. Once renamed, you will shorten the whole path length, and you will be able to delete the folder tree.Geoff Courts, Operations Manager, Macnamara IT www.macnamara.it
Free Windows Admin Tool Kit Click here and download it now
May 29th, 2012 4:17am

I use "Long Path Tool" in this situation and it helps me well.
October 4th, 2012 11:57am

Cant rename/ delete/ copy file? Please look that, LONG PATH Error Fixer helped me in this situation. Actually Long Path Tool is so usefully for this problem. So try it today.
Free Windows Admin Tool Kit Click here and download it now
October 20th, 2012 3:00pm

Use 'RoboCopy' to mirror (/mir) an empty folder (that you create) in to the directory that you wish to delete. Reference: http://superuser.com/a/296241/56505
October 22nd, 2012 1:12pm

Dear friend, Try this command... Via command-Prompt go to directory where is there the requested file and type: > del /Q "filename" Ex. C:\Documents and Settings\User\Desktop\ > dir > del /Q "testfile.txt"
Free Windows Admin Tool Kit Click here and download it now
October 23rd, 2012 10:13am

Dear friend, Try this command... Via command-Prompt go to directory where is there the requested file and type: > del /Q "filename" Ex. C:\Documents and Settings\User\Desktop\ > dir > del /Q "testfile.txt" Code Chief answered this question competently some 18 months ago. Your answer does not add anything useful to his solution because it does not work.
October 23rd, 2012 10:36am

Another option is to create a junction using Junction Link Magic or NTFS Link (or the command line). This is rather like subst, but better - you can create a folder C:\x which is just a hardlink to, say, C:\Areallylongfoldernameindeed. This may shorten the total path enough to allow you to manipulate the file.
Free Windows Admin Tool Kit Click here and download it now
December 4th, 2012 6:28pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics