bin/TODO/mp3-tag-setter.sh
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
#!/usr/bin/env bash
# by AAAAAAAA
# assumes that mp3 files-to-be-tagged are named accordingly:
# Track # - Artist - Title.mp3
#
# TODO: get semi-working
# TODO: run shellcheck on this file once it works
# TODO: use mutagen/mid3v2 because it's better and more up-to-date
#
# sets tag $TAG for every .mp3 file in the currecnt directory
set_tag() {
echo "Type in the field name _exactly_: "
read "FIELD"
for i in *.mp3 ; do ${TAGEDITOR} ${TAG} ${FIELD} "$i"; done
}
# reads song titles from textfile, as well as ARTIST and ALBUM variables,
# assumes song title order in file matches up with filename order in current
# directory, then renames accordingly
rename_mp3s() {
MP3FILELIST="$(ls -1)"
while LINE= read -r line
do
# something with $line
done < $INPUTFILE
}
# sets variables for command and flags for the id3 tag editor of choice
TAGEDITOR="id3tag" # id3tag comes with id3v2, which is in the Arch repo
ALBUM_FLAG="-A"
ARTIST_FLAG="-a"
YEAR_FLAG="-y"
TRACK_NUM_FLAG="-t"
TITLE_FLAG="-s"
WELCOME="mp3-tag-setter.sh Version 0.2\n \
This script applies to every .mp3 file in the current directory.\n \
Note: actions with (*) require the files to be named accordingly:\n \
Track# - Artist - Title.mp3\n \
Would you like to:\n \
1) Set the album\n \
2) Set the artist\n \
3) Set the year\n \
4) Set track numbers (*)\n \
5) Set track titles (*)\n \
6) Mass rename of files according to pre-defined textfile (is own thing)\n"
echo -e $WELCOME
read "ACTION"
case $ACTION in
1)
TAG="$ALBUM_FLAG"
set_flag()
;;
2)
TAG="$ARTIST_FLAG"
set_flag()
;;
3)
TAG="$YEAR_FLAG"
set_flag()
;;
4)
# set track numbers from filename
#
;;
5)
# set track titles from filename
#
;;
6)
# renames a set of .mp3s IN ORDER according to ordered list in a textfile
# echo an explanation as to how this works
#
echo "Type in the name of a textfile with song titles: "
read INPUTFILE
rename_mp3s()
;;
*)
echo "Invalid action. Please type 1, 2, 3 or 4."
;;
esac
# sets titles in metadata
#for i in *.mp3; do TITLE="$(echo $i | awk 'BEGIN{FS="-"} {print $3}' | sed 's/.mp3//g')"; id3tag -s "$TITLE" "$i" ; done
|