dotfiles

Unnamed repository; edit this file 'description' to name the repository.
git clone git://git.margiolis.net/dotfiles.git
Log | Files | Refs | README | LICENSE

tag (1347B)


      1 #!/bin/sh
      2 
      3 usage()
      4 {
      5 	echo "usage: ${0##*/} [-a artist] [-A album_title] [-c comment]" 1>&2
      6 	echo "	[-d year] [-g genre] [-n trackno] [-N totalno]" 1>&2
      7 	echo "	[-t song_title] file" 1>&2
      8 	exit 1
      9 }
     10 
     11 xread()
     12 {
     13         printf "%s" "${1}" && read -r ${2}
     14 }
     15 
     16 while getopts "a:t:A:n:N:d:g:c:f:" arg; do
     17 case "${arg}" in
     18 	a) artist="${OPTARG}" ;;
     19 	t) title="${OPTARG}" ;;
     20 	A) album="${OPTARG}" ;;
     21 	n) track="${OPTARG}" ;;
     22 	N) total="${OPTARG}" ;;
     23 	d) date="${OPTARG}" ;;
     24 	g) genre="${OPTARG}" ;;
     25 	c) comment="${OPTARG}" ;;
     26 	f) file="${OPTARG}" ;;
     27 	*) usage ;;
     28 esac
     29 done
     30 shift $((OPTIND - 1))
     31 
     32 file="${1}"
     33 test ! -f "${file}" && echo "${0##*/}: file not found" && usage
     34 
     35 test -z "${title}" && xread "Title: " title
     36 test -z "${artist}" && xread "Artist: " artist
     37 test -z "${album}" && xread "Album: " album
     38 test -z "${track}" && xread "Track number: " track
     39 
     40 info="Title=${title}
     41 Artist=${artist}
     42 Album=${album}
     43 Track=${track}
     44 Total=${total}
     45 Date=${date}
     46 Genre=${genre}
     47 Comment=${comment}"
     48 
     49 echo "${info}"
     50 
     51 case "${file}" in
     52 	*.ogg)	echo "${info}" | vorbiscomment -w "${file}" ;;
     53 	*.opus)	echo "${info}" | opustags -i -S "${file}" ;;
     54 	*.mp3)	eyeD3 -Q --remove-all \
     55 			-a "${artist}" \
     56 			-A "${album}" \
     57 			-t "${title}" \
     58 			-n "${track}" \
     59 			-N "${total}" \
     60 			-Y "${date}" \
     61 			"${file}" ;;
     62 	*)	echo "${0##*/}: file type not implemented yet" ;;
     63 esac