4

Im copying some files from one hard drive to another via drag and drop. I got some errors about filenames being too long. Admittedly, the files that wont copy are probably nothing anyone cares about, but still, I have to wonder about how to avoid such problems in the future. enter image description here

j0h
  • 15,365

2 Answers2

6

There is a limit to file name length that cannot be exceeded. This limit differs by the filesystem type and sometimes gets shorter if the filesystem is also encrypted.

You can find out what the limit is on your system by running getconf NAME_MAX on a partition like so:

getconf NAME_MAX /dev/sda1

The output would be the maximum filename length in bytes ( 1 byte = 1 character ) and it will print something like this:

255

There is a path limit too which you can find by running getconf PATH_MAX on a partition like so:

getconf PATH_MAX /dev/sda1

The output would also be the maximum path length in bytes ( 1 byte = 1 character ) and it will print something like this:

4096

When copying files, the limit of the destination filesystem is applied as these files will be created in the destination and if their filenames exceed the maximum filename limit for the destination filesystem, the copying process will result in an error and these files will not be copied.

The easy workaround for this is to rename these files to something shorter and copy them again.

Raffa
  • 34,963
0

seems if you use onedrive,
you manipulate the folder in the browser gui,
the onedrive sync tool installed locally could evade this error and still successfully finish the copy paste operation.

Luk Aron
  • 101
  • 1