summaryrefslogtreecommitdiff
path: root/amg
diff options
context:
space:
mode:
Diffstat (limited to 'amg')
-rwxr-xr-xamg20
1 files changed, 11 insertions, 9 deletions
diff --git a/amg b/amg
index 9162e6b..4a9297c 100755
--- a/amg
+++ b/amg
@@ -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"