How can Filename too long be avioded in a copy-paste operation?

Solution 1:

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.