Commit 75b473cb authored by Cédric Marie's avatar Cédric Marie
Browse files

mycdrip/tag-sieve: Update disc/track number prefix



Audio filenames are prefixed with disc and track numbers. The format
has changed, to make the filenames shorter:
"01 - Title.flac" is replaced with "01. Title.flac"
"1 - 01 - Title.flac" is replaced with "1.01. Title.flac"

Both mycdrip and tag-sieve must be adapted to comply with this new
convention.
Signed-off-by: default avatarCédric Marie <cedric.marie@openmailbox.org>
parent 1bd019bf
......@@ -3,7 +3,7 @@
# mycdrip - Extract audio tracks from a CD and convert them to FLAC
# This file is part of Painted Shell - Shell configuration and scripts.
#
# Written in 2016 by Cédric Marie <cedric.marie@openmailbox.org>
# Written in 2016-2017 by Cédric Marie <cedric.marie@openmailbox.org>
#
# To the extent possible under law, the author(s) have dedicated all copyright
# and related and neighboring rights to this software to the public domain
......@@ -45,17 +45,17 @@ print_header "Step 2: Convert to .flac files"
flac --delete-input-file --no-seektable *.wav
if [ -z "$1" ]; then
print_header "Step 3: Rename files (## - .flac)"
print_header "Step 3: Rename files (##. .flac)"
else
print_header "Step 3: Rename files ($1 - ## - .flac)"
print_header "Step 3: Rename files ($1.##. .flac)"
fi
for file in *.cdda.flac;
do
file_nb=${file#track}
file_nb=${file_nb%.cdda.flac}
if [ -z "$1" ]; then
mv -v "$file" "$file_nb - .flac"
mv -v "$file" "$file_nb. .flac"
else
mv -v "$file" "$1 - $file_nb - .flac"
mv -v "$file" "$1.$file_nb. .flac"
fi
done
......@@ -3,7 +3,7 @@
# tag-sieve - Clean audio tags
# This file is part of Painted Shell - Shell configuration and scripts.
#
# Written in 2014-2016 by Cédric Marie <cedric.marie@openmailbox.org>
# Written in 2014-2017 by Cédric Marie <cedric.marie@openmailbox.org>
#
# To the extent possible under law, the author(s) have dedicated all copyright
# and related and neighboring rights to this software to the public domain
......@@ -188,7 +188,7 @@ if [ "$command" = "clean" ]; then
fi
tag_tracktotal=`grep "^TRACKTOTAL=" $tags_filename | tail -n 1`
tag_tracktotal=${tag_tracktotal#TRACKTOTAL=}
if [ "${file%% - *}" = "1" ]; then
if [ "${file%%.*}" = "1" ]; then
multi_disc=1
tag_discnumber=`grep "^DISCNUMBER=" $tags_filename | tail -n 1`
tag_discnumber=${tag_discnumber#DISCNUMBER=}
......@@ -293,7 +293,7 @@ if [ "$command" = "clean" ]; then
tag_album=${tag_album#*: }
tag_date=`grep "^TYER " $tags_filename`
tag_date=${tag_date#*: }
if [ "${file%% - *}" = "1" ]; then
if [ "${file%%.*}" = "1" ]; then
multi_disc=1
fi
......@@ -587,7 +587,7 @@ if [ "$command" = "upt" ]; then
while read file
do
# Remove .flac and leading disc and track numbers
tag_title=`echo ${file%.flac} | sed 's/^[1-9] - //' | sed 's/^[0-9]\+ - //'`
tag_title=`echo ${file%.flac} | sed 's/^[1-9]\.//' | sed 's/^[0-9]\+\. //'`
printf "$file: \033[7m$tag_title\033[0m\n"
metaflac --set-tag="TITLE=$tag_title" "$file"
done
......@@ -607,7 +607,7 @@ if [ "$command" = "upt" ]; then
while read file
do
# Remove .mp3 and leading disc and track numbers
tag_title=`echo ${file%.mp3} | sed 's/^[1-9] - //' | sed 's/^[0-9]\+ - //'`
tag_title=`echo ${file%.mp3} | sed 's/^[1-9]\.//' | sed 's/^[0-9]\+\. //'`
printf "$file: \033[7m$tag_title\033[0m\n"
id3v2 --id3v2-only --song "$tag_title" "$file"
done
......@@ -632,11 +632,11 @@ if [ "$command" = "uptn" ]; then
first_file=`ls -1 *.flac | grep -m 1 flac`
if [ "${first_file%% - *}" = "1" ]; then
if [ "${first_file%%.*}" = "1" ]; then
multi_disc=1
current_disc=
last_file=`ls -1r *.flac | grep -m 1 flac`
tag_disctotal=${last_file%% - *}
tag_disctotal=${last_file%%.*}
print_header "Set track/disc numbers from filename and track/disc total in all tracks"
else
tag_tracktotal=`ls -1 *.flac | grep -c flac`
......@@ -651,16 +651,16 @@ if [ "$command" = "uptn" ]; then
while read file
do
# Remove .flac and leading disc number (if present)
tag_tracknumber=`echo ${file%.flac} | sed 's/^[1-9] - //'`
tag_tracknumber=`echo ${file%.flac} | sed 's/^[1-9]\.//'`
# Get the track number without leading 0
tag_tracknumber=${tag_tracknumber%% - *}
tag_tracknumber=${tag_tracknumber%%.*}
tag_tracknumber=${tag_tracknumber#0}
if [ "$multi_disc" = "1" ]; then
tag_discnumber=${file%% - *}
tag_discnumber=${file%%.*}
if [ "$tag_discnumber" != "$current_disc" ]; then
# Get the number of tracks for this disc
current_disc=$tag_discnumber
tag_tracktotal=`ls -1 ${tag_discnumber}\ -\ *.flac | grep -c flac`
tag_tracktotal=`ls -1 ${tag_discnumber}.*.flac | grep -c flac`
fi
metaflac --set-tag="DISCNUMBER=$tag_discnumber" "$file"
metaflac --set-tag="DISCTOTAL=$tag_disctotal" "$file"
......@@ -680,11 +680,11 @@ if [ "$command" = "uptn" ]; then
first_file=`ls -1 *.mp3 | grep -m 1 mp3`
if [ "${first_file%% - *}" = "1" ]; then
if [ "${first_file%%.*}" = "1" ]; then
multi_disc=1
current_disc=
last_file=`ls -1r *.mp3 | grep -m 1 mp3`
tag_disctotal=${last_file%% - *}
tag_disctotal=${last_file%%.*}
print_header "Set track/disc numbers from filename in all tracks"
else
tag_tracktotal=`ls -1 *.mp3 | grep -c mp3`
......@@ -699,16 +699,16 @@ if [ "$command" = "uptn" ]; then
while read file
do
# Remove .mp3 and leading disc number
tag_tracknumber=`echo ${file%.mp3} | sed 's/^[1-9] - //'`
tag_tracknumber=`echo ${file%.mp3} | sed 's/^[1-9]\.//'`
# Get the track number without leading 0
tag_tracknumber=${tag_tracknumber%% - *}
tag_tracknumber=${tag_tracknumber%%.*}
tag_tracknumber=${tag_tracknumber#0}
if [ "$multi_disc" = "1" ]; then
tag_discnumber=${file%% - *}
tag_discnumber=${file%%.*}
if [ "$tag_discnumber" != "$current_disc" ]; then
# Get the number of tracks for this disc
current_disc=$tag_discnumber
tag_tracktotal=`ls -1 ${tag_discnumber}\ -\ *.mp3 | grep -c mp3`
tag_tracktotal=`ls -1 ${tag_discnumber}.*.mp3 | grep -c mp3`
fi
id3v2 --id3v2-only --TPOS "$tag_discnumber/$tag_disctotal" "$file"
printf "track \033[7m$tag_tracknumber\033[0m / \033[7m$tag_tracktotal\033[0m, disc \033[7m$tag_discnumber\033[0m / \033[7m$tag_disctotal\033[0m: $file\n"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment