Fix: Cannot Delete File, The File Name You Specified Is Invalid Or Too Long

Martin Brinkmann
Aug 15, 2010
Updated • Dec 29, 2012
Windows, Windows tips

Files or folders can sometimes not be deleted because of file name restrictions in Windows. See, Windows supports file names of up to 255 characters, which includes the directory path. If a directory or file surpasses that limit it cannot be deleted. Many users at this moment assume a corrupt file on the hard drive that is preventing the deletion. While that is a possibility, it may be simpler than that.

The error message reads (variants possible):

cannot delete file: the file name you specified is invalid or too long. Specify a different file name.

The following trick may help in removing the file and the directory structure from the system. Please note that it is not necessary to count the characters used in the file path, if it looks extraordinarily long then it may use indeed more characters than the allowed maximum.

the file name you specified is not valid or too long

We have already established that deletion does not work. The best option? Renaming. It is still possible to rename directories or the file name, so that the total count drops below the character limit. This can be done both in Windows Explorer, or on the command line. Just select a folder, and rename it to a single character. Repeat the procedure until the file path length has dropped considerably.

Deleting the file and folder structure should then work both in Windows Explorer and the command line. There are other solutions on how to cope with this situation. Another possibility is to map a drive to a folder in the path, to shorten the url structure, or to find a software or operating system that can manipulate those files and folder structures.

Did you ever encounter files that could not be deleted because of their length? What have you done to fix the situation?

You may also ask yourself how those structures appear on your system. It can be that you have downloaded and extracted an archive that included a nested folder structure, or are using a data drive on Windows and another operating system that does not have these restrictions. Whatever the reason, your best bet of deleting, renaming or moving files or folders if you receive the "not valid or too long" error is to shorten its path by renaming folders.


Tutorials & Tips

Previous Post: «
Next Post: «


  1. Pravin Gunjal said on August 29, 2020 at 2:58 pm

    I do not understand this solution, can you please thro some light on it. As in my case, I have an external drive “E” for pen drive and unable to delete some *.mp3 files. Can you help me out on this issue.

    1. Civ said on March 18, 2023 at 7:40 pm


  2. christos said on March 14, 2019 at 9:55 pm


    by moving the folder closer to root the overall name characters count was reduced


  3. philip said on February 18, 2014 at 2:43 am

    Unlocker works fantastic. just when installing it, antivirus will detect a virus and block the virus only, but the rest of program will continue to install. just wait for it.

  4. Ian C Teig said on November 6, 2013 at 3:28 am

    Solution that worked for me:

    Start from the root directory you are attempting to delete, rename every folder going down the tree to a single character, I did the alphabet. By the time I hit M, I was able to delete the contents.

    Hope that helps.

  5. garrydam said on August 26, 2013 at 1:51 pm

    With downloading “Long Path Tool” you will be able to fix your long path errors.

  6. adamdee said on August 9, 2013 at 8:20 am

    Try and download ” Long Path Tool ” is also useful in situations where you see these error messages: Cannot read from source file or disk, there has been a sharing violation, cannot delete file or folder, the file name you specified is not valid or too long, the source or destination file may be in use and many other file managing errors.

  7. Sir_Roman_Athens said on July 28, 2013 at 5:47 pm

    DO NOT USE THIS “Tool”!!!

    I believe it caused my computer to have repeat BOOTS; Crashing My computer constantly until I was able to correct it (on my own) as my tried-and-true anti-malware software was Unable to detect and remove it!

    I performed the http://www.VirusTotal scan on it. All the engines (except one, Trend Micro) gave it a clean bill of health. TM informed that LPT was actually a T-R-O-J-AN!

    I will stick with my Teracopy from now on.


    1. saman said on April 9, 2020 at 8:11 am

      My case is so critical that even I can’t upload it to virustotal! They’re some unknown files that have filled my flash memory space but I can’t delete even rename them! And unlocker couldn’t do anything about them! I’m searching but any new idea is appreciated…

  8. Frederik Dawin said on February 28, 2013 at 11:12 am

    Have you tried using Long Path Tool? I have the same problem as yours and it had been resolved using that tool. Check it.

  9. krowey said on February 9, 2013 at 2:11 am

    Sometimes simplifying the file or folder name doesn’t work.And if you have 3000+ files, im sure you can’t rename them all. So the best thing to do i guess is to use a third party app like longpathtool. It can solve issues like this and errors like 1320 in windows 7. i hope this can help.

  10. novelltes karrychay said on February 6, 2013 at 3:38 pm

    Have you tried long path tool it is the best software it will help you

  11. JuliaBrin said on January 24, 2013 at 4:35 pm

    Why don’t you check out Long Path Tool? It would be very useful, it would help you solve your problems. Check it out.

  12. Peter said on November 30, 2012 at 12:47 pm

    Brilliant – what an easy solution: Renamed all folders to one letter and then could delete them. Thanks!

  13. Adrian Hauberg said on November 24, 2012 at 3:00 am

    I was having this issues with my 2 gig SD card. I was unable to delete some (maybe corrupt) files because “the filename you specified is not valid or too long”. I couldn’t delete the files at all. I’m running windows 7. I fixed the issue by right clicking the SD file and then clicked “Format”. It erased everything on it. Of course, I was careful to make sure there was nothing on it that I cared about. Make sure you transfer all files that you want to save before doing this. They WILL be lost otherwise.

  14. GabrielNar89 said on November 19, 2012 at 5:45 pm

    This is a Windows* OS/file system issue.The cause is directory paths on the drive is longer than 255 characters (including spaces).There’s a lot of additional softwares which can fix this problem like Long Path Tool.
    Long Path Tool can simplify and probably end your problems in unlocking, managing and renaming files that appear to have a long filename. Since in some instances, you may have experienced problems accessing, managing and even renaming files that have more than 255 characters, this utility has been made to answer this particular scenario. If you have also encountered problems like error messages that tell you that the path too long, too long path, destination path too long or cannot delete file then this program is definitely for you. This will totally take place of Windows Explorer, Far Manager or other file managing utilities since this is maybe used in any type of Operating System even the earliest Windows 95 version.

  15. Gurjot said on October 29, 2012 at 11:33 am

    Followed the advice in this article by shortening the folder names successively to reduce the length of the file name, and voila! I was able to delete the offending files in a jiffy! Thanks for the simple solution.

  16. Tom Ward said on August 5, 2012 at 11:12 pm

    Use a software program called DelinvFile

  17. Baba said on December 18, 2011 at 10:37 am

    I am also faced the same problem but i got the solution from the

  18. alan.larky said on December 31, 2010 at 7:04 am

    i also have faced the same problme and following software sort out my problem

    Little features of this softwares are:

    Path too long.
    Error cannot delete file: cannot read from source file or disk.
    Cannot delete file: Access is denied.
    There has been a sharing violation.
    Cannot delete file or folder The file name you specified is not valid or too long.
    Specify a different file name.
    The source or destination file may be in use.
    The file is in use by another program or user.
    Error Deleting File or Folder
    Make sure the disk is not full or write-protected and that the file is not currently in use.
    Path too deep.

    1. Ivanna Zhyljuk said on March 2, 2012 at 11:55 am

      Just in case anyone is interested:
      long path tool moved to

  19. Ionut Stoian said on October 27, 2010 at 5:21 pm

    Do you have error messages?, like :
    Cannot delete file: Access is denied
    There has been a sharing violation.
    The source or destination file may be in use.
    The file is in use by another program or user.
    Make sure the disk is not full or write-protected and that the file is not currently in use.

    If yes, our progam will be helpful for you.

    Windows Explorer/FAR would fail to copy/delete/rename any pathname longer than 256 characters. Our program LONG PATH Tool can handle pathnames of any length, up to the internal Windows limit of 32,000 characters.

    Fast speed of long path folder/files search.
    No special system requirements. LONG PATH Tool works on any Windows version (NT/2000/XP/Vista/Windows 7).
    Delete system locked files
    Can delete files even from mapped network folders
    Can list files and paths which have file path more than 200 characters long.
    Close application that uses the file
    Unload locking process
    Copy and delete files and folders
    Delete after reboot
    Omits file name you specified is not valid or too long

  20. Diego said on August 18, 2010 at 2:27 pm

    This command was a useful solution for me:

    Create a virtual drive from directory where the problem is, then try to delete/rename the stuck file/folder.

    Hope this help.

    1. Diego said on August 18, 2010 at 2:31 pm

      Another terrific tool is FastCopy.

      Internally it bypass the 255 Windows chars limitations when copying/deleting.

  21. damfiles said on August 18, 2010 at 12:24 pm

    had this problem with a file downlaoded from net, too long a name and also Zero bytes, xp gave me no choice but to reinstall if i wanted rid of the dam file, xp didnt recognise it as a file because it was seemed to not even be a file, but there it was! and nothing i tried , renaming, going into dos to rename/delete !

  22. The_Flames said on August 17, 2010 at 11:16 pm

    I like the solution at this site :)

    1. Rarst said on August 18, 2010 at 6:46 am

      Heh, I should have probably linked to this in my comment above. :)

  23. Jehad said on August 17, 2010 at 10:17 pm

    back in the time (the age of Windows 98 and ME) i used to go directlyto DOS booting and head to the directory of the file, since DOS will not show that very name (instead; it will shorten it with a hyphen in the end) you can so easily delete it.

    in case of Windows XP, the only way i remeber using was to go safe mode and delete the cursed file.

  24. TSR said on August 17, 2010 at 6:01 am

    I have this problem on a regular basis as Mac users on our server create directory structures 10 levels deep and then find they can’t rename or move a file. Windows has no problem creating the long paths but can’t delete them. The only thing that has work has been to create shares at some point in the path, delete the files, create a new share, etc. until the path is cleaned up.
    Of course, they will go and the same thing again the next day…

  25. Kenneth M. Aspinwall said on August 16, 2010 at 7:06 pm

    Unlocker works sometimes, but when it doesn’t, first I try to delete via a command line, if that doesn’t work then I use a live CD to boot into linux and delete the file(s) there.

  26. Transcontinental said on August 16, 2010 at 3:49 pm

    I haven’t had exactly this problem but one similar to, which was having a zero-bite file unable to remove because the system just couldn’t read it, for the system there was no such file ! That was a few years ago and I had finally found an application which read and removed the file … I have an old version but the website and application are still going strong:

    JRT Wine Software, LLC – Delete FXP Files

    If it can help as it had helped me, great !

  27. Colin said on August 16, 2010 at 12:16 pm

    I have had some success using the DOS command SUBST to cut a long path down to a drive letter.

  28. frank said on August 16, 2010 at 9:10 am

    Did not have problems with too long ones, but with under windows in filesnames not allowed chars like the ” : “. It was impossible to rename the file. So just started Ubuntu Live CD and renamed the file. It might also work for too long filepaths?

  29. Carl said on August 16, 2010 at 4:47 am

    I usually map a drive partway into the path and then dig into the mapped drive to delete the file.

  30. Will said on August 16, 2010 at 4:47 am

    One of the options in unlocker is to rename the file / folder.

    Works fine for me every time I come access this mess. So I too vote for unlocker.

    Of course Microsoft should just fix the bug in the first place!!

  31. Hysterian said on August 15, 2010 at 11:22 pm

    Problem is in charset. Any program dont see this named file, some yes but cannot delete or run. Solution is rename it to normal system charset and then delete. Bigger problem is folder, if you use rename or copy, it makes copy to file, not a folder. scandisk or checkdisk cant correct this….. solution is to use a filemanager with correct charset (ascii)

  32. Rarst said on August 15, 2010 at 10:15 pm

    From my experience Unlocker doesn’t help with overly long paths. I get such regularly at work with one of programs. There might be differences of Windows versions and other specifics of course, in my case it fails.

    I use batch script that recursively destroys folder tree with robocopy.

  33. Mike said on August 15, 2010 at 9:42 pm

    I am a fan of unlocker and have been using it for years. It’s one of my goto tools along with Sysinternals Process Explorer and other utils. BUT there are times when doing all of the above and using every other ‘delete/unlock’ tool will not work. What I have found is that the long filename and ‘directory not empty’ thing can be fixed by using a bulk file rename tool 1st renaming the file(s) and or directories incrementally like 001 etc., then deleting (sometimes still with unlocker). There are loads of freeware bulk file/dir renamers around so I won’t list them use Google. I see this alot with incomplete backup file restores.

  34. paul(us) said on August 15, 2010 at 8:55 pm

    Martin, Mehdi S is right i often encounter this problem and unlocker is always doing, the trick for me. Great program.

    1. Martin said on August 15, 2010 at 9:05 pm

      Great, did not know that.

  35. Bruce said on August 15, 2010 at 8:41 pm

    Unlocker dose work. I use it in the field for this exact problem.

  36. jasray said on August 15, 2010 at 7:45 pm

    Hmmm . . . should be able to go to Task Manager, end process –explorer.exe, delete file, and restart explorer.exe. Maybe MoveOnBoot. Hard to say–heard about the problem; never had to personally deal with it.

  37. FL said on August 15, 2010 at 7:12 pm

    I understand an embedded feature of windows is the virtual impossibility or removing ‘too long’ file names. Often they are created when visiting websites and therefore may contain information a user want’s to delete.

    One way to circumvent such issues is to use sandboxie ( by ensuring that the software/browser that creates such ‘too long’ file names is captured within a sandboxie container. The container can also be placed on a ram disk, so everything just vanishes at shutdown.

    The container could also be placed on a separate disk or usb stick, which can be overwritten/erased/formatted when needed.

    The only way to give accurate advice is to be advised which program created the file name or cut and paste a copy of it here, indicating which folders it is contained in.

  38. Mehdi S said on August 15, 2010 at 5:19 pm

    unlocker ftw…

    1. RBR said on April 15, 2020 at 2:01 pm

      NOTHING worked. No Command tricks, no PowerShell tricks, NOTHING. It hit me. It wasn’t JUST the filename, but the entire pathname. It would not let me rename the file, but going back to the root directory, and drilling into about 4 layers thick, then renaming the next folder in the path to 1, then the next one to 1 and the next and the next. Finally I was able to delete 1\1\1\1\1\1\1\obsolete_file.txt I was then able to delete any rouge folders and then rename the remaining folders back. (Hint–if you can’t remember the folder names, write them down first. Office staff typically does not like it when you ask “what was that folder’s name supposed to be again?”)

      1. Anonymous said on April 30, 2020 at 3:16 am

        THANK YOU Trick with multiple “1” worked for me! Very nice!

    2. Martin said on August 15, 2010 at 5:23 pm

      I do not think that Unlocker can help in this case.

      1. Bob said on April 1, 2019 at 7:33 pm

        The solution is simple.
        Example: c:/folder/folder/folder/nameoffilethatistolong.txt
        Change each folder name to f so c:/f/f/f/changthename.txt

      2. Anonymous said on January 13, 2021 at 5:55 am

        txs, it works

      3. Mehdi S said on August 16, 2010 at 7:30 pm

        Maybe I’m wrong, but i’d swear I used unlocker for that bug before…As for your trick, I used to do that too :)

Leave a Reply

Check the box to consent to your data being stored in line with the guidelines set out in our privacy policy

We love comments and welcome thoughtful and civilized discussion. Rudeness and personal attacks will not be tolerated. Please stay on-topic.
Please note that your comment may not appear immediately after you post it.