I am trying to copy some files with long file names onto an old Windows XP 32bit FAT32 system and I am getting errors of having too long file names. How could I recursively search through a directory for file names greater than or equal to 255 chars and truncate them as appropriate for a FAT32 filesystem?
Share
I’m sure
findcan do the whole job, I couldn’t quite get the last step so resorted to using somebashfoo:Using
findto get all the files with filename greater than or equal to 255 characters:find . -maxdepth 1 -type f -regextype posix-extended -regex ".{255,}"Truncate those filenames to 50 characters,
-ndo not overwrite an existing file.mv -n "$filename" "${filename:0:50}"Note: Can this be with the
-execoption anyone?