How to delete – Destination Path Too Long

Well, it’s fairly simple to delete files and folder with destination path too long and name. In windows world, you will act a little over smart and witty, map the path as mapped drive and delete the file/folder. But what if, you have a billion files (may be that’s little bit too much 🙂 ) that you need to remove, you can’t keep mapping the drive and deleting the files.

There is better way of handling this situation. The solution doesn’t come from Windows world however it comes from Linux (quite amazing & amusing) world which works pretty well on windows.

So here is how it goes.

You need to download and install Cygwin (A linux emulator on windows). You can download Cygwin from here https://cygwin.com/install.html

It comes in both x86 (32 bit) and x64 versions. The setup is under 1 mb and uses internet connection to download dependencies and packages to install full functional Cygwin emulator.

Note: In case you are looking for portable version of Cygwin, you can download it from www.cybesystems.com

cygwin setup

cygwin setu - choose istallation type

cygwin setup - choose installation directory

nus.edu.sg is the nearest location to where I am based and It’s National University of Singapore. You may want to select some other location based on your region.

By default, the dependencies packages would be selected automatically and you don’t need to select any other package.

Once Installed, you can launch the Cygwin terminal from Start > or directly from the install location.

Destination path too long - fix

In above real world issue, I was working on the DFS-R replication issue, where I had to purge DFSR folder under System Volume Information and delete the contents. Now, literally, it has hundreds of thousands of file which could be deleted otherwise, due to path Destination Path Too Long issue.

Notice, the way you browse to the drive and directory is different from windows.

Once you are under at the correction location, issue the following command

you can get the view the help using the following command

Now we would use the rm (remove) command with few switches to delete the directory containing files with long names and destination.

rm -f -r -d -v “foldername”

The above command would delete the parent directory and everything underneath without being stopped for destination path too long error.

Important: Note that the above screenshot doesn’t show DFSR.old path however the command rm was run under DFSR.old directory. Don’t run it under System Volume Information.

Hope this helps.

Previous

AWS Billing and Cost Management Tools

Next

Step by Step: How to Export AWS EC2 Instances to Excel file

2 Comments

  1. Abigail

    Long Path Tool is very helpful for handling this situation.

Leave a Reply

Copyright © 2018, All Rights Reserved.