diff options
author | zachir <zachir@librem.one> | 2023-12-11 12:43:39 -0600 |
---|---|---|
committer | zachir <zachir@librem.one> | 2023-12-11 12:43:39 -0600 |
commit | 7d60a0023f6eefd5c3f05bffee4f31a01ac4e17f (patch) | |
tree | 2b80635b3380be4df20761ff8f748d4bb1cf3b0c /amg | |
parent | 5b1b85995adcbba2b6057d270c3637c8763eb0b3 (diff) |
Because these files will need to be synched to potentially multiple
filesystems and OSes, I just delete all non-alphanumeric symbols
(although for the sake of the script I will replace them with _ to
denote that there should be a symbol there).
Diffstat (limited to 'amg')
-rwxr-xr-x | amg | 20 |
1 files changed, 11 insertions, 9 deletions
@@ -142,19 +142,21 @@ for file in `ls *.mp3`; do printf "\n$TRACKNUM doesn't look like a track number!\n" 1>&2 ;; esac - [ -n "$ARTIST" ] && kid3-cli -c "set 'Artist' '$ARTIST'" "$file" - [ -n "$ALBUM" ] && kid3-cli -c "set 'Album' '$ALBUM'" "$file" - [ -n "$TITLE" ] && kid3-cli -c "set 'Title' '$TITLE'" "$file" - [ -n "$TRACKNUM" ] && kid3-cli -c "set 'Track Number' '$TRACKNUM'" "$file" - [ -n "$YEAR" ] && kid3-cli -c "set 'Date' '$YEAR'" "$file" + FMT_ARTIST="$(echo "$ARTIST" | sed "s/[^[:alnum:].-]/_/g")" + FMT_ALBUM="$(echo "$ALBUM" | sed "s/[^[:alnum:].-]/_/g")" + FMT_TITLE="$(echo "$TITLE" | sed "s/[^[:alnum:].-]/_/g")" + [ -n "$ARTIST" ] && kid3-cli -c "set \"Artist\" \"$ARTIST\"" "$file" + [ -n "$ALBUM" ] && kid3-cli -c "set \"Album\" \"$ALBUM\"" "$file" + [ -n "$TITLE" ] && kid3-cli -c "set \"Title\" \"$TITLE\"" "$file" + [ -n "$TRACKNUM" ] && kid3-cli -c "set \"Track Number\" \"$TRACKNUM\"" "$file" + [ -n "$YEAR" ] && kid3-cli -c "set \"Date\" \"$YEAR\"" "$file" printf "\n\n$file\n" kid3-cli -c get "$file" - printf "\n" - NEWFILENAME="${ARTIST}_-_${ALBUM}_-_${TRACKNUM:-00}_${TITLE}.mp3" - NEWFILENAME="$(printf "%s" "$NEWFILENAME" | sed 's/ /_/g;s/[!@#$%^&*()-_=+{}\|;:,.<>/?`~'"\[\]\'\""']//g')" + NEWFILENAME="${FMT_ARTIST}_-_${FMT_ALBUM}_-_${TRACKNUM:-00}_${FMT_TITLE}.mp3" + #NEWFILENAME="$(printf "%s" "$NEWFILENAME" | sed 's/ /_/g;s/[!@#$%^&*()-_=+{}\|;:,.<>/?`~'"\[\]\'\""']//g')" [ -n "${ARTIST}" -a -n "${ALBUM}" -a -n "${TITLE}" ] && mv "$file" "$NEWFILENAME" unset TITLE TRACKNUM - printf "\n$NEWFILENAME\n" + printf "$NEWFILENAME\n\n\n" done printf "\n\nDone.\n" |