How to delete a long path in windows.

Baltimark picture Baltimark · Feb 15, 2009 · Viewed 58.3k times · Source

When importing a project into eclipse, it somehow started creating recursive versions of the directory.

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

I can't delete it from the command shell. I can't delete it from explorer. I can't do ANYTHING with it. I have no idea how many copies of it Eclipse created. Eclipse was running for like a minute before I realized something was wrong and I cancelled the operation.

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

Question 1: how can I delete all this stuff in Windows?

Question 2: What the hell was eclipse thinking?

Answer

gonsalu picture gonsalu · Jul 23, 2010
robocopy empty_dir base_nested_dir /purge

Example: If you have a folder path that's too long such as:

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 delete it.

  1. Create an empty folder, such as C:\Users\Name\Desktop\temp.
  2. Open a Command Prompt window.
  3. Type robocopy C:\Users\Name\Desktop\temp D:\BackupFolder /purge

Note: If there are spaces in either path in Step 3, the path must be inclosed by quotation marks.