How to remove a long path in windows.

When importing a project into eclipse, it somehow began to create recursive versions of the directory.

Now, when I try to delete something, I get the message "the file name you specified is too long."

I can not remove it from the shell. I cannot remove it from explorer. I can do nothing about it. I do not know how many copies of this Eclipse have been created. The eclipse ran like a minute before I realized that something was wrong and I canceled the operation.

I can get the properties of the top-level folder, and it says it contains 497 folders.

Question 1: how can I remove all these things in windows?

Question 2: What the hell outshone thinking?

+57
eclipse windows path
Feb 15 '09 at 15:48
source share
19 answers

I had a problem with Eclipse: when I tried to import a project using Subclipse, it created a deeply nested set of directories that I could not delete.

I did a couple of things, firstly, I edited the directory names to the shortest possible length (in fact, I think it was pointless). Secondly, I crossed the directory tree as deep as possible, and then cut and pasted the branch (which allows me to delete the original branch), and then repeated the process.

Solutions

@Charlie and @Tomalek look like they can be more elegant. I do not plan to repeat the experience to find out about it.

+19
Feb 15 '09 at 16:20
source share
robocopy empty_dir base_nested_dir /purge 

Example. If your path to the folder is too long:

D:\BackupFolder\Copy\MyFiles\BackupFolder\Copy\MyFiles\BackupFolder\Copy\MyFiles\BackupFolder\Copy\MyFiles\BackupFolder\Copy\MyFiles\BackupFolder\Copy\MyFiles\BackupFolder\Copy\MyFiles\BackupFolder\Copy\MyFiles\BackupFolder\Copy\MyFiles\BackupFolder\Copy\MyFiles\BackupFolder\Copy\MyFiles\BackupFolder\Copy\MyFiles\BackupFolder\Copy\MyFiles

Follow these instructions to remove it.

  • Create an empty folder, for example C:\Users\Name\Desktop\temp .
  • Open a command prompt window.
  • Type robocopy C:\Users\Name\Desktop\temp D:\BackupFolder /purge

Note. If there are spaces in any path in step 3, the path must be enclosed in quotation marks.

+152
Jul 23 2018-10-23T00:
source share

7Zip is the ultimate solution if you are not comfortable with the command line.

  • Open 7Zip File Manager
  • Browse to file
  • Shift-Delete File

Hurrah!

+81
Jan 22 '15 at 15:39
source share

Regarding Q1)

Use sub for short circus paths:

 subst Q: C:\very\long\path\created\by\eclipse Q: del *.* 

Regarding Q2)

Long paths are not a problem on other operating systems, and there are Windows API functions that can handle paths longer than 255 characters, so they just did it, I think.

+12
Feb 15 '09 at 15:55
source share

If you need to process paths longer than MAX_PATH , you will have to use Unicode versions of the Windows APIs (e.g. DeleteFileW ) and use the \\ prefix? \. You can write a short program using these APIs to list these directories and delete them.

+10
Feb 15 '09 at 15:57
source share

The fix is ​​simple and free! No need to rename folders at all.

  • Download Cygwin for free.

  • use the command rm -f -r <folder-name> and wait a few minutes.

I had a 1.5 GB folder with numerous internal folders, and it worked!

+6
Oct 08 2018-10-10T00:
source share

I ran into the same problem using eclipse ..! Zillion subfolders were created and it took over 500 MB of space !!!!

I tried a lot of things in the windows and nothing worked.

Finally, I just rebooted using ubuntu and deleted this horrible folder .. just like that .. ubuntu doesn't seem to have any access restrictions based on the length of the file path, like windows do. makes life so much easier .. :)

+4
Feb 19 2018-10-19
source share

The method mentioned in this post of the Windows Sysinternals forum by maxaha1 was specified .

I suggest you work from top to bottom. As long as you stay in the same volume (share), you can usually drag and drop top-level directories to new parents, regardless of the contents of the directory (that is, the length / recursion problems that may occur). So you take the catalog, possibly 4 or 5 levels along your path to the problem, and drag it to the root. Then delete the original path, which now only contains several levels. Ideally, work to keep the longest path to less than 250 characters (including file names). I am performing a system migration at the moment, and we have some users with 340 + char paths that cannot be copied without this method. I tried using sub, recursive network usage, recursive scripts, etc. Unfortunately, users seem to be able to create things that confuse the best coders, administrators, etc.

Create new folders and just drag them down, several folders from top to bottom (and delete them) until you clear them.

+4
Aug 24 2018-11-11T00:
source share

The previous three answers are obviously spam (for the payware demo). If you want to get a free solution with one click, see here:

http://www.osmstudios.com/Display.asp?Page=pathtoolong

Which probably uses 3-line Java from this thread.

-FM

+4
Apr 11 2018-12-12T00:
source share

Programmatically, you can delete using DeleteFileW and RemoveDirectoryW and add L"\\?\" To the file names. Note that you need to use the W version, not the API version.

+3
08 Feb 2018-11-21T00:
source share

Someone above has already posted a link to "rimraf", but let me add more details. If Node is installed on your system, just use the rimraf module (it can be installed in your path). This is by far the easiest way to remove things on a Windows system in the most non-trivial cases. It is not that rimraf is awesome, in fact, because Node.js handles file systems at the device core level. If you look at the source code for the fs module for Node, you'll see code like this . In fact, Node.js handles file systems much better than even Git for Windows, i.e. There is an error using Git clean -fdx on Windows that does not delete folders with long path names.

+3
Aug 03 '15 at 17:59 on
source share

Lol I had a similar problem a few years ago. Due to an error, I created an indefinite nesting of folders until the file name dragged on for too long.

IIRC, I deleted them programmatically by scanning the folder structure.

+1
Feb 09 '11 at 6:40
source share

I did not like any of the solutions posted here and elsewhere (robocopy, 7zip, subst, shady spyware), so I deployed my own command line tool.

It can recursively delete a file or an entire directory. Perhaps in the future I will add more options.

The tool is called SuperDelete , and you can get it from the releases page of GitHub .

+1
Dec 13 '15 at 7:55
source share

Ok, I tried to find a solution for this, and I found one of the easiest solutions for Windows users.

  • Install Mobaxterm
  • Open mobaxterm. Go to the directory you want to delete (using cd) and run the following command

    rm -rf directoryname

All folders, subfolders whose windows complain about deletion will now be deleted.

+1
Dec 22 '15 at 4:24
source share

MIR (mirroring a complete directory tree) worked for me also on network and window network networks.

robocopy empty_dir <foldertobedeleted> /MIR

  • Just create an empty directory and say robocopy to clear everything in the destination directory that is not in the empty directory

the conclusion will be like this.

enter image description here >

+1
Aug 08 '17 at 8:05
source share

It is rather annoying that in 2016, this still presents us with Windows users a problem when Linux solved these years ago. This made it even more annoying when it is easy to do in Java.

We must use Change.org to apply for MS to enable this ability. It's not hard. If they are concerned about backward compatibility, why not just use the Strict mode, which administrators can turn on or off. At least give us a warning, but then let us remove it anyway. GRRRRR [/ rant]

If you use Java on your computer, you may find this code useful:

 import java.io.File; public class Delong { public static void main(String[] args) { File file = new File("F:\\YourDirectory\\YourFile"); boolean result = deleteDirectory(file); if(result) System.out.println("Deleted"); else System.out.println("Failed"); }//end main /** * Force deletion of directory * @param path The path you want to delete * @return True if it worked; */ static public boolean deleteDirectory(File path) { if (path.exists()) { File[] files = path.listFiles(); for (int x = 0; x < files.length; x++) { if (files[x].isDirectory()) deleteDirectory(files[x]); else files[x].delete(); }//end for }///end if return (path.delete()); }//endDeleteDirectory }//end class 
0
Apr 28 '16 at 1:10
source share

You can use "Cygwin" with the command "rm -force --recursive PATH" or "rm -fr PATH".

-one
Nov 13 '14 at 8:55
source share

If you already have git installed on your system, then an easy way to delete the folder with all its contents is to open the gitbash window and then run this command.

$ rm -rf DeleteFolderName

-one
Oct 19 '16 at 10:40
source share

Try using unlocker . It is used to kill processes that contain file locks, but I think that it can forcibly delete files with the extension, for example, you have it.

-2
Feb 15 '09 at 15:56
source share



All Articles