Skip to content

Instantly share code, notes, and snippets.

@axtstar
Created January 20, 2014 00:38
Show Gist options
  • Save axtstar/8512991 to your computer and use it in GitHub Desktop.
Save axtstar/8512991 to your computer and use it in GitHub Desktop.
eyeD3を利用して、MP3にタグ情報を付与します。
#/bin/bash
#timetable is someyhing like crontab.
#dirpath is directory you want to add information.
#Display the usage with using wrolgly
if [ $# -le 1 ]; then
echo "usage : $0 [timetable] [dirpath]"
exit 1
fi
#Set variables from command line args
timetable=$1
dirpath=$2
#Read the timetable from file and store it into hash
artist="NHK"
album=""
title=""
#Set ID3 tag to Files
for e in $(find ${dirpath} -type f)
do
#filename
filename=$(basename ${e})
#separete first part of filename
target=$(echo ${filename} | awk 'BEGIN{FS="_"}{print $1}')
#separate second part of filename
title2=$(echo ${filename} | awk 'BEGIN{FS="_"}{print $2}')
#search timetable
tt=$(cat $timetable | grep $target)
t2=$(cat $timetable | grep -1 $target)
title=$(echo ${t2} | awk 'BEGIN{FS="#"}{print $2}' )
album=$(echo ${tt} | awk 'BEGIN{FS=","}{print $1}' )
eyeD3 --artist "${artist}" --album "${title}" --title "${title2}" "${e}" --preserve-file-times
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment