Link to home
Start Free TrialLog in
Avatar of Dan
DanFlag for United States of America

asked on

copying files that the path is too long

Hi, I have a client that has super deep directories, they can keep making them, but when I try to use Robocopy or GSCopy pro it errors out if the folder path is too deep.

Question, is there a way to copy around files when the data path is super deep?  a command line program would be my first choice, but I'll adapt.

Thanks all.
Avatar of jmcg
jmcg
Flag of United States of America image

I think the free utility FastCopy can handle this problem. It has a command-line interface as well.
Avatar of Joe Winograd
There was a thread about this here at EE last year where this tool was recommended:
http://longpathtool.com/

I have not tried this myself, but am simply passing it along for your consideration. Regards, Joe
This thread on Tom's Hardware included an allegation that the longpathtool.com demo created a long path that could not be removed without purchasing the program. Just sayin'.

I've found that such problematic files can be dealt with successfully by using a DOS window "dir /x" command to obtain the short name. Deleting the file via the short name works. Or rmdir on a problematic folder, once you've emptied it out. But it gets pretty tedious if the folder hierarchy is deep.
Avatar of ☠ MASQ ☠
☠ MASQ ☠

I'd also caution about longpathtool, this site did get spammed a bit last year by them in threads containing those keywords.

Have you tried using Unicode file naming to copy in Robocopy

"\\?\C:\Longname\"

Should copy any long path name from C:\Longname
(You need that closing backslash)

\\?\ works because it uses Unicode not Windows file naming
Here's the EE thread where Long Path Tool was mentioned:
https://www.experts-exchange.com/questions/28497775/can't-copy-folders-Files-with-long-names.html

Lots of other stuff in there. A worthwhile read for anyone with this issue.

And here's another, more recent, Tom's Hardware thread where Long Path Tool was mentioned:
http://www.tomshardware.com/answers/id-2287767/file-long-copy-laptop-fine-external-hdd.html

I haven't tried it because my file manager handles long file names just fine. I've been using the excellent Total Commander as my file manager for many, many years:
http://www.ghisler.com/

When trying to copy a too-long-file-name, it gives a dialog saying that the target name length is more than 259 characters and offering to keep the name, keep all, skip the file, skip all, rename, or abort. The release notes from the version that implemented this feature (in 2009) said;
Support for file names longer than 259 characters (up to 1022) in most file operations
Also, to avoid the dialog mentioned above, you may set an option called LongNameCopy in its configuration file, as follows:
LongNameCopy: During file operations, warn if target name is longer than 259 characters:
0=always
1=never
2=if source name isn't longer than 259 characters
3=disallow long names
Regards, Joe
Or use the subst command to make the path shorter.

Example

Instead of C:\abaddef\efefefefef\efeefef\eeggg

use

subst z: C:\abaddef\efefefefef\efeefef\eeggg

and then copy z: across.  Now this depends on your folder structure as to whether that would be satisfactory or not.
ASKER CERTIFIED SOLUTION
Avatar of oBdA
oBdA

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Dan

ASKER

So I'm getting that robocopy will copy as long as I use a trailing "\" in the path?

c:\data\
not c:\data
The trailing backslash has nothing to do with it. In addition, if you need quotes around the path because there's a space in the name, the backslash will escape the closing quote and lead to errors.
Just forget about the long path and let robocopy do its job. It's that easy. Really. Been there, done that.
%Systemroot%\system32\robocopy.exe "C:\Source\Folder" "D:\Target\Folder" *.* /e /r:0 /w:0 ...

Open in new window

The XP010 version of robocopy and higher do indeed not have a problem with long paths.
I would actually use the latest standalone version available which is version XP026.
You can download it here:
http://technet.microsoft.com/en-us/magazine/2006.11.utilityspotlight.aspx
http://download.microsoft.com/download/f/d/0/fd05def7-68a1-4f71-8546-25c359cc0842/UtilitySpotlight2006_11.exe
The package does also include a GUI.
The GUI does use the installed "robocopy.exe" file.
-------------------------------------------------------------------------------
   ROBOCOPY     ::     Robust File Copy for Windows     ::     Version XP026
-------------------------------------------------------------------------------

You can use this "robocopy.exe" from the command line and also copy the file to another computer and run it from there.

As the utility is very old I'm actualy not sure if the utility installs correctly on Windows 7 and higher. On Windows XP/2003 the setup works fine. The robocopy.exe file can however be used without any problem on Windows 7 and higher.