4

I'm helping my uncle transferring all his photography images from a Windows machines internal and external hard drives to his newly bought NAS and we stumbled across a little problem (happening to 'only' 3.000 files..), called 'File name/folder name too long to copy'. So.. I'm looking for an application that can find all files with a certain name length for me.

Windows Explorer can search by name, type, size, etc. but as far as I can tell it cannot search by name length. Therefor I'm looking for an application that can do so.

Note: This may be a prompt command providing that the outcome can simply be exported.


Bonus! Also applicable on the command prompt: changing file/folders name from the same application! Dashes, dots and spaces are in fact unnecessary and can result in shorter names, thus perhaps possible to transfer!

10
  • Shorten the folder names to those pictures, maybe you don't need to find out which file names are too long after doing that. Windows has a limit of 255 characters for a name, including path names. If the whole path to the file has more characters, you get the error message when copying.
    – daraos
    Commented Mar 13, 2016 at 22:21
  • Gotta find out if that applies also to Synology's OS, since that is the target folder. Thanks, clever! Commented Mar 13, 2016 at 22:22
  • i've done something like c:\blah>dir /s/b>a.a that gets a list of all filenames in a file a.a, and then open the file a.a in notepad and turn off word wrap and scroll right and scroll down and you see the longest paths. You could also open it in notepad++ and look for ways to sort by length of line.
    – barlop
    Commented Mar 13, 2016 at 22:27
  • Excuse me, I really got no clue what you are talking about, @barlop .. Commented Mar 13, 2016 at 22:28
  • 4

2 Answers 2

5

The Windows Explorer as well as .NET Framework applications have problems with paths that exceed 260 characters (see here: https://stackoverflow.com/questions/1880321/why-does-the-260-character-path-length-limit-exist-in-windows)

What you can do to circumvent this is simply shorten the path by means of mapping it to a drive letter with subst.exe like this:

subst.exe <DriveLetter>: <super long path without trailing backslash>

Example:

subst.exe A: C:\users\%username%\appdata\local\temp

This maps my super long path (C:\users\%username%\appdata\local\temp in this case) to the drive letter A: thus reducing the path length by more than 20 characters. This also works with UNC paths on your NAS.

The drive is visible in the Windows Explorer so you only have to open the commandline to map the drive. It'll automatically be unmapped when you log off/reboot the PC.

1

I'll shortcut your problem.

Your filespecs (the combination of the 8.3 filename and folder name) exceed the 255 character limit. This is likely due to deeply nested folders.

For the files that cannot be moved, move their folders to the root of the drive, and then perform the transfer operation. It should now work.

4
  • It would work if the new path is within the 255 char limit, which is likely.. but the destination path might have to be changed. And it's possible the filename is longer than it should be.
    – barlop
    Commented Mar 13, 2016 at 22:25
  • A quick thought: Most files that cannot be copied because of this error are located on internal NTFS drives. Each file has no issue staying there, which brings my thought: If they have no problem then the 255 character limit doesn't apply to them, so it shouldn't be the issue when moving them elsewhere. Or how should I see this? Commented Mar 13, 2016 at 22:27
  • @SanderSchaeffer it's possible to have a file existing there whose path exceeds the 255 limit, but then not be able to copy it. You ask a valid question of how did it get there, maybe it's possible to rename a file or create a file that exceeds the limit, but then have an issue copying it. There may be a way to copy it though just an issue with windows explorer copying and some others but. e.g. according to this, robocopy can do it stackoverflow.com/questions/29865863/…
    – barlop
    Commented Mar 13, 2016 at 22:29
  • It depends on how each application is written. Some applications, for example those written to use .NET, have their own limitations (260 chars). Commented Mar 13, 2016 at 22:29

Not the answer you're looking for? Browse other questions tagged .