Link to home
Start Free TrialLog in
Avatar of E=mc2
E=mc2Flag for Canada

asked on

File too long to be copied

When coping folders and files from a server share to a Sharepoint share, on occasion I will get a message that says the file is too long to be copied over.
Is there a way to overcome this?
The copying is being done on a Windows Server 2012 R2 server and being done with copy and paste method.
Avatar of David Favor
David Favor
Flag of United States of America image

Post your exact error message (cut & paste).

Likely the message is that the file name is too long + this applies to your target file name.

Likely fix is to shorten the directory structure your copy target file name.
Avatar of E=mc2

ASKER

The file is being copied to a destination where the file did not exist.
Without having to trim the file name, is there another solution?
Post your actual error message, full command + error return for best answers.

And... no... if the target file name is the problem, you must shorten your target directory or filename, so full path (dir + file) meet OS path link requirements.

Note: Path max length is compiled into the OS, so there's no changing this.
Map a drive to the deepest folder then perform the copy using the mapped drive.
This will shorten the path and unless the file name it's self is too long you should be able to copy the file.
if you are using robocopy put ' ' around the path  "c:path thats too long"
If you're using windows explorer to drag and drop, you won't be able to copy file paths longer than 260 characters.  Windows NTFS has always been able to recognize longer paths, but Windows programs were artificially limited to not access longer paths.

You might be able to overcome this with the \\server\share syntax
https://docs.microsoft.com/en-us/windows/desktop/FileIO/naming-a-file#maxpath

You can somewhat overcome this in Windows 10, but I haven't checked if Server 2012 has this; Server 2016 might:
from https://www.howtogeek.com/266621/how-to-make-windows-10-accept-file-paths-over-260-characters/
Open regedit.exe
Navigate to
  HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem
Edit
   LongPathsEnabled
and set the value to 1

You used to be able to map the directory to a drive letter to shorten the path, but Microsoft crippled this somehow by putting the full mount path in the Volume label when you map the drive.  The alternative is to create a directory junction to map the long path to a shorter path on the same drive letter.

mklink /j C:\short_name C:\path\to\very\long\long\long\name\that\exceeds\260\characters\

Open in new window


Once you make the directory junction, you can then copy the files into or out of the path .

Otherwise, use robocopy.exe to copy it.  That used to be a resource kit tool, but is now include as part of standard windows.  Sysadmins should always be using robocopy to copy files and not use drag and drop.  It's faster and more robust.  You also don't waste time having Explorer.exe enumerating 100,000+ files before a copy can start.

You can also use a Linux or OS X system to mount the drive and copy it, but that may change the access control ownership and permissions.

That 260 character path limit was already obsolete in every other OS since the 1990s.  It should have been changed long ago.  NTFS on NT4 already supported longer paths, because I was dealing with that Microsoft file length limit crap even back then because of linux/unix sharing with Windows.  MIcrosoft needs to fix their obsolete, broken API.  This problem has existed for more than 20 years now, yet it's still broken.
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.