Instantly share code, notes, and snippets.

Embed
What would you like to do?
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