diff options
author | zachir <zachir@librem.one> | 2022-08-12 04:30:51 -0500 |
---|---|---|
committer | zachir <zachir@librem.one> | 2022-08-12 04:30:51 -0500 |
commit | c4d96716c05c41a3b18f2326cb588cd19246da5f (patch) | |
tree | aa6b16c2e89ee63d37eb05e38577ec0b0bddea59 /tagmp3 |
initial commit
Diffstat (limited to 'tagmp3')
-rwxr-xr-x | tagmp3 | 79 |
1 files changed, 79 insertions, 0 deletions
@@ -0,0 +1,79 @@ +#!/sbin/sh + +FILENAME=`echo $@ | rev | cut -d' ' -f1 | rev` + +# check for flags +for i in $@; do + case "$i" in + "-"*) unset ARTISTFLAG ALBUMFLAG SONGFLAG + ;; + esac + [ -n "$ARTISTFLAG" ] && ARTISTNAME="$ARTISTNAME $i" + [ -n "$ALBUMFLAG" ] && ALBUMNAME="$ALBUMNAME $i" + [ -n "$SONGFLAG" ] && SONGNAME="$SONGNAME $i" + [ -n "$TRACKFLAG" ] && TRACKNUMBER="$i" && unset TRACKFLAG + [ -n "$YEARFLAG" ] && YEARNUMBER="$i" && unset YEARFLAG + case "$i" in + "-a") + ARTISTFLAG="y" + ;; + "-A") + ALBUMFLAG="y" + ;; + "-t") + SONGFLAG="y" + ;; + "-T") + TRACKFLAG="y" + ;; + "-y") + YEARFLAG="y" + ;; + esac +done + +ARTISTNAME=`echo $ARTISTNAME | sed 's/^ //'` +ALBUMNAME=`echo $ALBUMNAME | sed 's/^ //'` +SONGNAME=`echo $SONGNAME | sed 's/^ //'` + +# guess artist name from title +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'` + +# guess track number from title +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$//'` + +# get the artist name input +[ -z "$ARTISTNAME" ] && echo "Input the Artist name:\nGuessed name is $ARTISTNAME_GUESS" && read 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" ] && 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" ] && 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" ] && SONGNAME="$SONGNAME_GUESS" + +echo "$SONGNAME" + +# get the year input +[ -z "$YEARNUMBER" ] && echo "Input the year number:" && read YEARNUMBER +[ ! -z "$YEARNUMBER" ] && mid3v2 -y "$YEARNUMBER" $FILENAME +# set tags for file +mid3v2 -a "$ARTISTNAME" -A "$ALBUMNAME" -t "$SONGNAME" -T "$TRACKNUMBER" $FILENAME |