Looking for a utility to copy file with *nix long filenames to a FAT32 thumbdrive with 8.3 filenames

I have about 26Gb of music files my dear wife wants to be able to listen to with the car stereo, which can play mp3s.

But it uses FAT32 and those awful short filenames and I don't want to do each file individually, for obvious reasons like my sanity would never endure that.

Anything that can translate the names from "this is a long filename that most Linux filesystems handle with aplomb.mp4" to "bummer01.mp4" short names that are directory unique. If it can also do the copying that would be glorious.

My :duck: :duck: :running_woman:t4:-fu is usually strong, but I can't find a thing like it, so I'm a bit worried the answer is "no such critter". I don't want to have to write a script :sob:

Any advanced Linux file renaming utility should be able to handle that. You would need to specify the rules that the names would by modified with. KDE has Krename, there are many others.

You may find though that the stereo has a limitation on the maximum size of the thumb drive or the number of files it will permit in the root of the drive. At least I have found this in the past. Some stereos will choke on too many music files on a single large drive.

Good luck.

3 Likes

fat32 shouldn't require 8.3 filenames.

3 Likes

The stereo does.
EDIT: Oh, I see I made it sound like it’s the filesystem. Sorry!

Yeah, but I don’t want to have to duplicate all the files, rename them, then put them on the thumb drive. I may be being picky though.

The manual claims it will handle the 32Gb - but is silent on how many files it will index. Some risks must be taken! Excelsior! :crazy_face:

I thought fat32 automatically stored 8.3 versions of all the long filenames for backwards compatibility. Did you try just copying the files as-is and seeing what the stereo does with it?

3 Likes

oh zod. I have a personal policy to never do anything while tired. Problem with that is when tired I tend to be a bad judge of whether or not I'm tired. :crazy_face:

I apologize for wasting youor time, @dalto and @tbg.

Yes, fat32 does automatically have an 8.3 filename. And the long file names are mostly compatible.

The one problem I am actually having is with ":". An acceptable character for BTRFS and EXT* but a no-no for fat32. A far, far simpler problem to deal with.

Thanks for the help, though. Y'all are awesome!

5 Likes

The script, in case it or any part might help others.

DWTFYWT license, if it makes a difference to ya.

#!/bin/zsh

setopt NULL_GLOB
musd="/home/yui/Music"      # Source
flas="/run/media/yui/MUSIC" # Destination

cd "$musd"

# Glob to walk all subdirectoies
for dire in **/
do
    #Get lists of ogg and mp3 files
    ogg=($dire*.ogg)
    mp3=($dire*.mp3)
    
    #What's up list to keep mindless user amused
    echo "=--------------------> $musd/$dire"
    
    #Iterate the OGG files, rename for Fat32, then convert to mp3 with ffmpeg.
    for fi in "${ogg[@]}"
    do
        fo=$(echo "$fi" | sed -e "s/[:,', ]/_/g")
        fum=$fo:r".mp3"
        echo "================================================$flas/$fum:h"
        mkdir -p "$flas/$fo:h"
        ffmpeg -i "$musd/$fi" -n "$flas/$fum" # "-n" don't overwrite files already there (Allows for refreshing from the ogg sources later
    done
    
    #Just copy MP3s with conditioned file names
    for fi in "${mp3[@]}"
    do
        fo=$(echo "$fi" | sed -e "s/[:,', ]/_/g")
        echo "================================================$flas/$fo:h"
        mkdir -p "$flas/$fo:h"
        cp -n "$fi" "$flas/$fo"
    done
done
unsetopt NULL_GLOB

You need to look at zmv if you are using zsh. It is an incredible flexible renamer that can move files at the same time it renames them.

2 Likes

I shall. Thanks!

1 Like

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