summaryrefslogtreecommitdiff
path: root/tagmp3
diff options
context:
space:
mode:
Diffstat (limited to 'tagmp3')
-rwxr-xr-xtagmp334
1 files changed, 17 insertions, 17 deletions
diff --git a/tagmp3 b/tagmp3
index c6bfe4f..3474a90 100755
--- a/tagmp3
+++ b/tagmp3
@@ -1,9 +1,9 @@
#!/bin/sh
-FILENAME=`echo $@ | rev | cut -d' ' -f1 | rev`
+FILENAME="$(echo "$*" | rev | cut -d' ' -f1 | rev)"
# check for flags
-for i in $@; do
+for i; do
case "$i" in
"-"*) unset ARTISTFLAG ALBUMFLAG SONGFLAG
;;
@@ -32,50 +32,50 @@ for i in $@; do
esac
done
-ARTISTNAME=`echo $ARTISTNAME | sed 's/^ //'`
-ALBUMNAME=`echo $ALBUMNAME | sed 's/^ //'`
-SONGNAME=`echo $SONGNAME | sed 's/^ //'`
+ARTISTNAME="$(echo "$ARTISTNAME" | sed 's/^ //')"
+ALBUMNAME="$(echo "$ALBUMNAME" | sed 's/^ //')"
+SONGNAME="$(echo "$SONGNAME" | sed 's/^ //')"
-echo "\n$FILENAME\n"
+printf "\n%s\n\n" "$FILENAME"
# guess artist name from title
-ARTISTNAME_GUESS=`echo "$FILENAME" | cut -d'-' -f1 | sed 's/_*$//;s/_/ /g'`
+ARTISTNAME_GUESS="$(echo "$FILENAME" | cut -d'-' -f1 | sed 's/_*$//;s/_/ /g')"
# guess album name from title
-ALBUMNAME_GUESS=`echo "$FILENAME" | cut -d'-' -f2 | sed 's/^_*//;s/_*$//;s/_/ /g'`
+ALBUMNAME_GUESS="$(echo "$FILENAME" | cut -d'-' -f2 | sed 's/^_*//;s/_*$//;s/_/ /g')"
# guess track number from title
-TRACKNUMBER_GUESS=`echo "$FILENAME" | cut -d'-' -f3 | cut -d'_' -f2`
+TRACKNUMBER_GUESS="$(echo "$FILENAME" | cut -d'-' -f3 | cut -d'_' -f2)"
# guess song name from title
-SONGNAME_GUESS=`echo "$FILENAME" | cut -d'-' -f3 | sed 's/^_[0-9]*_//;s/_/ /g;s/\.mp3$//;s/\.flac$//'`
+SONGNAME_GUESS="$(echo "$FILENAME" | cut -d'-' -f3 | sed 's/^_[0-9]*_//;s/_/ /g;s/\.mp3$//;s/\.flac$//')"
# get the artist name input
-[ -z "$ARTISTNAME" ] && echo "Input the Artist name:\nGuessed name is $ARTISTNAME_GUESS" && read ARTISTNAME
+[ -z "$ARTISTNAME" ] && printf "Input the Artist name:\nGuessed name is %s" "$ARTISTNAME_GUESS" && read -r ARTISTNAME
[ -z "$ARTISTNAME" ] && ARTISTNAME="$ARTISTNAME_GUESS"
echo "$ARTISTNAME"
# get the album name input
-[ -z "$ALBUMNAME" ] && printf "Input the Album name:\nGuessed name is %s" "$ALBUMNAME_GUESS" && read ALBUMNAME
+[ -z "$ALBUMNAME" ] && printf "Input the Album name:\nGuessed name is %s" "$ALBUMNAME_GUESS" && read -r ALBUMNAME
[ -z "$ALBUMNAME" ] && ALBUMNAME="$ALBUMNAME_GUESS"
echo "$ALBUMNAME"
# get the track number input
-[ -z "$TRACKNUMBER" ] && printf "Input the track number:\nGuessed number is %s" "$TRACKNUMBER_GUESS" && read TRACKNUMBER
+[ -z "$TRACKNUMBER" ] && printf "Input the track number:\nGuessed number is %s" "$TRACKNUMBER_GUESS" && read -r TRACKNUMBER
[ -z "$TRACKNUMBER" ] && TRACKNUMBER="$TRACKNUMBER_GUESS"
echo "$TRACKNUMBER"
# get the song name input
-[ -z "$SONGNAME" ] && printf "Input the song name:\nGuessed name is %s" "$SONGNAME_GUESS" && read SONGNAME
+[ -z "$SONGNAME" ] && printf "Input the song name:\nGuessed name is %s" "$SONGNAME_GUESS" && read -r SONGNAME
[ -z "$SONGNAME" ] && SONGNAME="$SONGNAME_GUESS"
echo "$SONGNAME"
# get the year input
-[ -z "$YEARNUMBER" ] && echo "Input the year number:" && read YEARNUMBER
-[ ! -z "$YEARNUMBER" ] && mid3v2 -y "$YEARNUMBER" $FILENAME
+[ -z "$YEARNUMBER" ] && echo "Input the year number:" && read -r YEARNUMBER
+[ -n "$YEARNUMBER" ] && mid3v2 -y "$YEARNUMBER" "$FILENAME"
# set tags for file
-mid3v2 -a "$ARTISTNAME" -A "$ALBUMNAME" -t "$SONGNAME" -T "$TRACKNUMBER" $FILENAME
+mid3v2 -a "$ARTISTNAME" -A "$ALBUMNAME" -t "$SONGNAME" -T "$TRACKNUMBER" "$FILENAME"