SFTP compatibility option: cut long filenames

I have found that others as well as myself have run into the issue of too long filenames when using SFTP.

There seems to be no really viable solution yet(I think I saw a feature request where the filenames are encrypted inside a metadata-file).
What are the thoughts on an compatibility(and expert-only) mode that allows to specify a cut-after-max-length integer. Filenames would be cut after those count of characters. It could be configurable, whether the beginning or the end is cut.
Most of the files I have, that are too long, have a rather long title, followed by some sort of identifier (youtube-dl default), so ideally there should be no two same files.

EDIT: I would be willing to implement if interested.

welcome to the forum,

--name-transform truncate=N Truncates the file name to a maximum of N characters


rclone test info

1 Like

Oh wow, I did not know that! Thanks a lot!
Also I did not know about the various unicode characters, that explains a lot of things I ran into.
Can you maybe help me setup a least modifying ruleset?
My output for rclone test info --all is:

2025/07/25 00:09:36 EME operates on 1 to 128 block-cipher blocks, you passed 513
2025/07/25 00:09:36 EME operates on 1 to 128 block-cipher blocks, you passed 257
2025/07/25 00:09:36 EME operates on 1 to 128 block-cipher blocks, you passed 129
2025/07/25 00:09:38 EME operates on 1 to 128 block-cipher blocks, you passed 1025
2025/07/25 00:09:38 EME operates on 1 to 128 block-cipher blocks, you passed 513
2025/07/25 00:09:38 EME operates on 1 to 128 block-cipher blocks, you passed 257
2025/07/25 00:09:38 EME operates on 1 to 128 block-cipher blocks, you passed 129
2025/07/25 00:09:38 EME operates on 1 to 128 block-cipher blocks, you passed 1537
2025/07/25 00:09:38 EME operates on 1 to 128 block-cipher blocks, you passed 769
2025/07/25 00:09:38 EME operates on 1 to 128 block-cipher blocks, you passed 385
2025/07/25 00:09:38 EME operates on 1 to 128 block-cipher blocks, you passed 193
2025/07/25 00:09:40 EME operates on 1 to 128 block-cipher blocks, you passed 2049
2025/07/25 00:09:40 EME operates on 1 to 128 block-cipher blocks, you passed 1025
2025/07/25 00:09:40 EME operates on 1 to 128 block-cipher blocks, you passed 513
2025/07/25 00:09:40 EME operates on 1 to 128 block-cipher blocks, you passed 257
2025/07/25 00:09:40 EME operates on 1 to 128 block-cipher blocks, you passed 129
2025/07/25 00:09:46 ERROR : 0062-␀‛␁‛␂‛␃‛␄‛␅‛␆‛␇‛␈‛␉‛␊‛␋‛␌‛␍‛␎‛␏‛␐‛␑‛␒‛␓‛␔‛␕‛␖‛␗‛␘‛␙‛␚‛␛‛␜‛␝‛␞‛␟.txt: Failed to copy: Update Create failed: sftp: "Bad message" (SSH_FX_BAD_MESSAGE)
2025/07/25 00:11:03 ERROR : Encrypted drive 'crypt_media:test/rclone-test-info-zocacin2/test-base32768': not deleting files as there were IO errors
2025/07/25 00:11:03 ERROR : Encrypted drive 'crypt_media:test/rclone-test-info-zocacin2/test-base32768': not deleting directories as there were IO errors
2025/07/25 00:11:03 NOTICE: Failed to sync remote fs: Update Create failed: sftp: "Bad message" (SSH_FX_BAD_MESSAGE)
// crypt_media
stringNeedsEscaping = []rune{
	'/', '\x00'
}
maxFileLength = 143 // for 1 byte unicode characters
maxFileLength = 71 // for 2 byte unicode characters
maxFileLength = 47 // for 3 byte unicode characters
maxFileLength = 35 // for 4 byte unicode characters
canWriteUnnormalized = true
canReadUnnormalized   = true
canReadRenormalized   = false
canStream = true
base32768isOK = false // make sure maxFileLength for 2 byte unicode chars is the same as for 1 byte characters

Now ideally I would truncate to 143 characters if it is 1 byte unicode and up to 35 characters if there are 4 byte unicode characters, is there a way to achieve this? Also is it possible to truncate the beginning, instead of the end or vice versa?

convmv supports advanced path name transformations for converting and renaming files and directories by applying prefixes, suffixes, and other alterations


sftp + unicode + encoding + crypt
@kapitainsky might know?

Do you know whether this is usable for a mount, as I guess it will break some sort of POSIX compatibility?

Sorry but I am confused a bit. What exactly is your setup?

Are you using crypt remote?

Could you please post results of:

rclone config redacted

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.