Which program to delete a long path. How to delete a file or folder with a long name if Windows does not allow you to do this! The path to the source is too long - why?

Does the harmful Windows operating system prevent you from deleting a file and shouts that its “source path is too long”? In this article I will tell you how to easily and simply, without any programs, defeat this scourge by shortening the file name.

The path to the source is too long - why?

I would like to immediately explain why such a system warning appears and it is not possible to perform basic copying or deleting actions on a file (folder)…

The notification itself contains the answer to this question - the Windows file system does not support (does not understand) source file names longer than 255 characters.

But your file or folder name is short, for example, “Vacation Photos”? The fact is that the “stupid” system perceives the entire path to the file as its name. If your file or folder is located somewhere too deep in the file manager, then its name will look something like this...

So the name symbols are collected into a gang of more than 255 pieces.

How to delete a non-deletable file or folder in this case? It’s very simple - you need to shorten the file name (path) by renaming nested folders.

How to delete a file with a long name

I’ll show you with my example how to delete a file with a long name which, as the system writes, has too long a path to the source.

Yesterday I decided clean your computer from old backup copies of the site, but they did not want to be deleted. As you guessed, a warning appeared about the path to the source being too long...

Starting from the very first folder in this long path, I renamed several things...

...and tried again to get rid of the file with a now shorter name - it safely went to the land of deleted files.

Naturally, the new file (folder) name should consist of one character or number, as in my example.

This is how the problem of deleting files or folders with a long name is easily solved. This is not the only method of course. Can remove with special programs or through the registry - I just showed the manual method. For some it will take just a minute, for others it will take half an hour - it’s up to you to decide how to shorten the file name and the too long path to the source.

Up to new useful tips and interesting computer programs.

Here is an example of a folder structure that I called the “big nesting doll”:

As you can see, on drive “D” (Data) there is a source video folder, in it there is a “Movies” folder, in it there is “Everything you need to watch movies” and then in the same way a folder within a folder. At the same time, many folders have long names and names - more than 10-15 characters, which in total will give the volume of characters in all names more than 260. And if at the end of such a “matryoshka” there is a file, then it may turn out that you cannot work with it you can... Sometimes the system itself does not allow you to ultimately create a folder or file that exceeds the allowed number of characters, but sometimes for some reason this happens.

First, for beginners, I’ll explain what a file and folder path is. Path is the so-called address on the computer where the file or folder is located. For example, a file called “My file.txt” is located on the local drive D: in the “Documents” folder. Then the path to this file will look like this:

D:\Documents\My file.txt

Or, for example, this is what the path from the example above will look like, where I showed a complex folder structure.

As you can see, the number of characters in the path above is large and it is possible that at the end there will be a file or folder with a long name that you cannot delete.

When you try to delete a file with a long path name, you will receive a window with an error like this:

I tried to artificially recreate the problem and this is what I got.

On drive “D” I created a folder with the short name “1” and placed a file with a very long name in it. Here's an example:

Now I also rename that folder “1” to some very long name, for example:

Interestingly, Windows freely allows you to rename a folder to such a long name, despite the fact that the number of characters in the name of this folder + file name already exceeds 260! Well, after renaming the folder to a long name, I can no longer delete the file located in it and get the error shown.

Or here’s another example... I maintain the website of the Moscow Instrument-Making College, where I previously worked full-time, and sometimes I use a copy of the site on my computer to test some new “goodies” for the site. What if I install something bad and the website on the hosting dies? :) And so I check it on my computer and if everything is in order, then I set it up on a real website located on the hosting. So, one time I transferred the entire site from hosting to test one thing, and after I finished working, I decided to delete the folder with the site from my computer. After all, it weighs about 6 GB. The entire site was deleted, except for a number of folders. I started looking and saw that those folders that contained a file with a long name in the form of hieroglyphs were not deleted:

I tried to delete this file with a long name again and saw the same error that I mentioned above. I tried to rename it, but it doesn't work either. Well, I had to think about how to solve the problem.

How to solve the problem of deleting a folder/file with a long path name!

I tried 2 ways to delete a folder/file with a long name in the path to it. Both of them are not technically difficult (especially the 1st), so I think a beginner can handle it if he does everything exactly as I show:

    Rename multiple folders in the file path to a shorter name. This is the simplest solution that should already help many! Suppose you have a file in a folder with a very long name that you cannot delete, open, copy, and generally cannot work with.

    Then try simply renaming the folder in which the file with a long name is located, for example, to “1”. Let me return to one of the examples above. Here is a folder with a long name:

    Using standard Windows Explorer, I rename the name of that folder to “1” and this is what the path to the file now looks like:

    Now you can safely work with the file; the system will allow you to open, rename and delete it.

    If you have a long folder tree, i.e. like a nesting doll, in one folder there is another, in it there is another, then another, then start renaming from the very first folder from this nesting doll. Not with the last one on the list, but with the first one!

    It may be that there are a huge number of folders and you won’t be able to rename some of them due to the same error or it will take you a lot of time. In this case, I suggest the second method.

    The method is that you can take some folder, for example, in the middle of a common tree and connect it as a virtual disk. A virtual disk is something that reminds us of a regular local disk, but which is simply tied to a specific folder, for example, for quick interaction with it.

    Let's say you have a long path like this:

    D:\Video\My Movies\Everything you need to watch movies\Programs for watching movies\How to open MP4 movies\List of MP4 example movies\List of programs for opening MP4\What not to do when opening MP4 files

    Let's assume that in the very last folder we have some kind of problematic file that we cannot work with, since the path to it, as we see, is quite long :)

    We can take and connect one of the folders with a long name in the middle of the path as a virtual disk. Let this be the “Programs for watching movies” folder.

    To connect a virtual disk, we need the so-called Windows command line, i.e. console.

    You can open it through Windows search. In the search, type “Command Line”:

    In the command line window we need to type the command:

    subst virtual_disk_letter "path_to_folder"

    You can set any drive letter, as long as it is not already occupied by one of the local drives. For example, you have a local drive C and D, which means you can no longer call the virtual drive with the same letter. You can call it, for example, the letter “X”, because it is rarely used in Windows.

    As a folder path, you insert the path to the folder that you want to connect as a virtual one. As I already said, in my example we’ll make “Programs for watching movies” as a virtual folder, which means the path needs to be specified like this:

    D:\Video\My Movies\Everything you need to watch movies\Programs for watching movies\

    So, the final command in my case will look like this:

    subst X: “D:\Video\My Movies\Everything you need to watch movies\Programs for watching movies\”

    To execute the entered command, press the “Enter” key on the keyboard. The virtual disk will be created.

    Now let’s go to Windows Explorer, go to the “This PC” (or “Computer”) section and see the created virtual disk there:

    You can distinguish it by its letter. I assigned the letter "X" to the virtual disk. Now if we open this virtual disk, we will immediately find ourselves in the “Programs for watching movies” folder. Those. we took and cut off half the path to the final folder.

    For comparison...

    Previously, the path to the final folder looked like this:

    D:\Video\My Movies\Everything you need to watch movies\Programs for watching movies\How to open MP4 movies\List of MP4 example movies\List of programs for opening MP4\What not to do when opening MP4 files

    After connecting the virtual disk to the “Programs for watching movies” folder, the path to the final folder looks like this:

    X:\How to open MP4 movies\List of MP4 example films\List of programs for opening MP4\What not to do when opening MP4 files

    Do you feel the difference? The path is shortened by half, since the drive letter immediately directs us to the folder in the middle of the path :) And since the path is greatly shortened, you probably now have removed the character limit in the names of files and folders and will be able to delete a file or folder with a long name!

    After you solve the problem with the file, the virtual disk can be deleted again so that it does not become an eyesore in Explorer.

    To do this, open the Windows command line again and enter the command:

    Subst virtual_disk_letter /d

    In my case the drive letter is “X”, so the command would look like this:

When I was thinking about options for solving the problem, how to delete a folder or file with a long name, I found another option on the Internet: delete the problematic file through the Total Commander program. I tried it, it didn’t work out, that’s why I didn’t recommend this method :)) And the method, even if it would work for someone, is honestly not fun, because you have to install an additional program on your computer in order to delete just one file or folders with a long name...

I think that if a similar problem occurs, which I have had more than once, one of the methods described above will definitely help you.

That's all! See you soon in the next articles;)

The title turned out to be long, but it indicates the essence of the problem that will be described here. Recently I encountered a not very good situation. While sorting the hard drive and clearing it of unnecessary things, I discovered that one of the files was not deleted, but the following error appeared: “The file system does not support such long source file names. Try moving the file to a folder with a shorter path length or specify a shorter file name and try again."

Not only could I not delete the file, but I also could not change the name to a shorter name. For many, this would seem like a dead end, because it turns out that the file is not deleted.

In fact, the problem can be solved very simply and quickly, and now I will describe two methods for solving it, and it’s up to you to decide which one to use.

What to do if the path to the source is too long, how to delete such a file?

If you have a file that is not deleted due to a long name, there are several options to solve the problem. For example, a file is nested in several directories, say five or even ten folders that have names of 10-20 characters, then this may be the reason for not deleting the file. The fact is that Windows does not support any files whose names have more than 260 characters. If this limit is exceeded, the error that I showed above will appear. The number of folders with their own names and the file name itself should total less than 260 characters. The system also has one feature - if this limit is exceeded, we can still rename folders. This means that you need to rename all folders to a short name, for example, a letter or number.


This problem may arise not only because you gave such a long name. This happened to me when I decided to download website files from the server and do something. Since the files were no longer needed, I deleted the entire directory with the site files, but as it turned out, it contained a file with a very long name, plus folder names, and this did not allow me to delete it all.

Method two will help if the first one failed. The fact is that not all folders leading to a file with a long name can be renamed and the same file system error will occur. Then you can create a virtual disk using any of the subfolders leading to the non-deletable file. Now I'll show you how to do this.

Open the command line. To do this, press the Win+R combination and enter the command cmd. You can right-click on the Start menu (or the Win+X key combination) and select Command Prompt there.

Now you write a command that will create a virtual disk for us:

You need to select a drive letter that is not occupied by others. The system partition is usually indicated as C, and the second partition as D or E, then select any other.

The path to the folder must be specified from the disk. If this is difficult for you, then open the folder that will act as a virtual disk and copy the path to it in Explorer at the top.

My command looks like this:

When we go to My Computer, you should see a drive there with the letter that we assigned to it from the command line. Thus, the path to the file will be reduced by almost half, which means that the total length of characters can be less than 260 characters. Now you can try to get rid of the undeletable.


In order to delete a virtual disk you need to enter the command:

substDiskLetter/d

Using Total Commander

On the Internet, I discovered a method that allows you to delete files that cannot be deleted using . Of course, the downside here is that you will have to install additional software on your computer, and not everyone will want to do this. In any case, I’ll leave this method here in case anyone wants to use it.

Download and install the program. Let's go to the tab "File" click on the section "Change attributes". A window appears where we remove the checkmarks from all attributes. If there is no checkmark next to the item at the top "Process directory contents"- choose. Now from the same program we try to delete a file with a long name.


We use the 7-Zip archiver

For this task we will need a 7-Zip archiver. Right-click on the starting directory and point the mouse at the partition "7-Zip" and select the item "Add to archive".

A window appears in which you only need to check one box. "Delete files after compression". Then click OK.

An archive of all this stuff is created on the desktop, and folders with long files are simply deleted. You can delete the archive itself without any problems.

These are the ways we have looked at to fix the file not being deleted error. Maybe you have other options on how to do this?

It's no secret that Windows Explorer, like most other Windows applications, including PowerShell, cannot work with file system objects with deep folder nesting. the path length of which exceeds 260 characters. Moreover, this limitation exists only at the application level, and the NTFS file system itself supports file paths up to 32767 characters.

This limitation is imposed by the library Win32 API, and whose maximum path length is 260 characters ( MAX_PATH=260). In general, the path is formed from the following elements: +[path_of_256_characters]+[ ] , and the maximum length of one directory/file in NTFS is 255 characters in Unicode. When using Unicode API functions, it is possible to use the path to 32767 characters. Thanks to this, many third-party programs (the same popular file managers, for example FAR And Total Commander) without any difficulty processes files/folders whose path length exceeds 260 characters.

Advice. You can bypass this limitation of the Win32 API and work with long file names by using the UNC path format, specifying the absolute path to the file using the extended-length path prefix \\?\ . For example, like this \\?\C:\SomeLongPath\LongNameFile.txt

This restriction also does not apply when users have network access to files via the SMB protocol (due to this, directory structures with long paths are common on file servers with user data). The administrator maintaining this server cannot manage (delete/move) files with long paths through the standard Windows Explorer interface. When trying to create/copy a file to such a directory, an error appears:

Destination Path Too Long. The file name (s) would be too long for the destination folder. You can shorten the file name and try again, or try a location that has a shorten path

Other programs/dialog boxes may report the presence of the restriction in their own way.

Agree, it’s funny that it’s 2014, and we’re still talking about the 260-character limit on the maximum path length in Windows... But it looks like no drastic changes are expected in the near future, and even in the very latest Windows 10 Technical Preview this limitation is still there still exists.

In this article we will show how in Windows you can work with files whose path exceeds 260 characters. In this case, our task is to delete a directory containing files with a long path length.

When you try to delete such a directory from Explorer, an error appears:

The file name(s) would be too long for the destination folder. You can shorten the file name and try again, or try a location that has a shorten path.

Powershell also cannot correctly handle directories and files with large paths exceeding 260 characters. When you try to delete a directory with such files (C:\Install\MS SQL 2012 Express Edition 64 bit\verylongpath), an error appears:

Remove-Item .\verylongpath -Recurse

Remove-Item: The specified path, file name, or both are too long. The fully qualified file name must be less than 260
characters, and the directory name must be less than 248 characters.
At line:1 char:1
+ Remove-Item .\verylongpath -Recurse
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo: WriteError: (C:\Install\MS S...it\verylongpath:String) , PathTooLongExcepti
on
+ FullyQualifiedErrorId: RemoveItemIOError,Microsoft.PowerShell.Commands.RemoveItemCommand

The simplest option (it is, in fact, suggested in the error window) is to shorten the name of the parent folders, reducing the total length of the path (but this is not always applicable).

Mklink /d c:\install\link “C:\Install\MS SQL 2012 Express Edition 64 bit\verylongpath”

Another option, reminiscent of working with a symbolic link, is to map the problematic folder to a virtual disk (in our example X:), thereby also reducing the path length:

Subst X: “C:\Install\MS SQL 2012 Express Edition 64 bit\verylongpath”

Now you can work with data on the X: drive, the paths to files in which will not exceed the limit. After finishing work, you can delete the virtual disk:

Subst X: /d

But personally, what I like most for the task of deleting data in such situations is the ability robocopy.exe, which supports working with long paths.

Using the option /MIR, the robocopy utility can create a complete copy (mirror) of the source directory in the target directory. And, if the source folder is empty, all data in the target folder is also cleared. Let's create an empty folder C:\Install\test and using the /MIR argument, copy the contents of the test folder to the target folder (if the folder name contains spaces or Cyrillic characters, the path must be enclosed in quotes).

Robocopy /MIR C:\Install\test "C:\Install\MS SQL 2012 Express Edition 64 bit\verylongpath"

After executing the command, the contents of the directory C:\Install\MS SQL 2012 Express Edition 64 bit\verylongpath are cleared (replaced with the contents of the empty directory).

So, today we showed some simple tricks that you can use when working with folders on file servers containing folders whose path length exceeds the 260 character limit.