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 -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
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.
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?
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.
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.
#!/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