diff options
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" |