Q

How to delete a file or folder when the Windows path is too long

Our expert answers a question on how to delete a file or folder when its Windows file name is beyond the Windows path length limit.

How do I delete files or folders when Windows complains "the path is too long?"

Windows has a number of rules on the maximum lengths possible for file names, directory names and path names. The maximum length for a Windows path name is generally 260 characters, although Windows also maintains -- via a parallel set of file-access application programming interfaces (APIs) -- the ability to access paths that are 32,767 characters long. Note that the latter way of accessing file paths is always absolute; you can't have a relative path name longer than 260 characters.

Because Windows is designed to err on the side of backward compatibility, the system defaults to using the old way of using path names. Many older programs would simply break if forced to work with the new API. The new path-name system requires a different naming convention for a path to alert the system about whichever file API you want to work with. Explorer and the command line default to the old naming system, which is why attempting to work with a path name that's too long will throw an error.

If you end up with a Windows path that is apparently too deep to be deleted, you can force the use of the alternate file-designation methodology to get around the 260-character limit. Here's how to do it:

  1. In Explorer, Shift-right-click on the item to be deleted and select "Copy as path."
  2. In a command prompt, type DEL and then paste the name of the path you copied (right-click and select Paste).
  3. Press Home to go to the beginning of the line, and modify the drive letter for the Windows path so that it reads \\?\<driveletter>:\. For example, if the path begins with D:\, modify so it reads \\?\D:\.
  4. Windows should delete the file or folder successfully.

Do you have questions for our experts? Email editor@searchenterprisedesktop.com.

This was last published in March 2013

Dig Deeper on User passwords and network permissions

PRO+

Content

Find more PRO+ content and other member only offers, here.

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Join the conversation

21 comments

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

i move the file to the root folder of the disk and then delete it. if you don't have permission to write on the root folder, move it to an usb device and then delete it.
Cancel
With Path too long error I use "Long Path Tool" to get fast and easy fix .
Cancel
I just download and use "Long Path Tool" guarantees to fix your error fast and easy.

--garrydam
Cancel
alternatively try this freeware http://backupchain.com/DeleteLongPath.html
Cancel
Well, you can use Long Path Tool, it really works good, I will say.
Cancel
Well, Only long path tool can help on this situation. Thanks
Cancel
I used iObit File Shredder. It's free.
Cancel
try Long Path Tool!!!!
Cancel
Well, you can use DuplicateFilesDeleter, it works good!
Cancel
The fast, best and automatic way to remove long path file is DuplicateFilesDeleter program. try is demo version and enjoy the facility of it and watch your PC running smoothly.
Cancel
I move the file to the Documents and then delete it.
Cancel
long path tool is used to sort out this problem
Cancel
create empty dir and from the command prompt run: robocopy x:\emptydir \\destination\dir\with\path\too\long /MIR /E
Cancel
Moved, fiddled, copied to another drive and finally deleted. Wish I'd known about Long Path Tool; would have saved me some time.
Cancel
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.
Cancel
I wonder if a simple RENAME would work. REN filetoolong*,* fileokay.*
Cancel
Have you tried software called Long Path Tool, it is absolute solution for such kind of errors.
Cancel
Try the long path tool. It is really awesome tool.
Cancel
the complaint of long file name specially at root or at deep level has often given a solution name path long tool, many good references i have noticed on forums.
Cancel
I used to have similar problems too, but after using "long path tool" everything was solved. Try this software and you would be glad you did.
Cancel
“Long path tool” is very helpful for this problem. You can solve this problem like copy, delete, long path files by using this tool.
Cancel

-ADS BY GOOGLE

SearchVirtualDesktop

SearchWindowsServer

SearchExchange

Close