summaryrefslogtreecommitdiff
path: root/amg
diff options
context:
space:
mode:
authorzachir <zachir@librem.one>2023-12-11 12:43:39 -0600
committerzachir <zachir@librem.one>2023-12-11 12:43:39 -0600
commit7d60a0023f6eefd5c3f05bffee4f31a01ac4e17f (patch)
tree2b80635b3380be4df20761ff8f748d4bb1cf3b0c /amg
parent5b1b85995adcbba2b6057d270c3637c8763eb0b3 (diff)
amg: Format fields when renaming fileHEADmaster
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-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"