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

tag-sieve: set all track/disc number/total tags



With command uptn, for FLAC files, set TRACKTOTAL tag, as well as
DISCNUMBER and DISCTOTAL tags in case of multi-disc.
Signed-off-by: default avatarCédric Marie <cedric.marie@openmailbox.org>
parent 01b3a365
......@@ -447,8 +447,21 @@ if [ "$command" = "uptn" ]; then
# FLAC files
if [ "$flac_files" != "" ]; then
print_header "Set disc and track numbers from filename in all tracks"
first_file=`ls -1 *.flac | grep -m 1 flac`
if [ "${first_file%% - *}" = "1" ]; then
multi_disc=1
last_file=`ls -1r *.flac | grep -m 1 flac`
tag_disctotal=${last_file%% - *}
else
tag_tracktotal=`ls -1 *.flac | grep -c flac`
fi
if [ "$multi_disc" = "1" ]; then
print_header "Set track/disc numbers from filename and track/disc total in all tracks"
else
print_header "Set track numbers from filename and track total in all tracks"
fi
# Set read-write permission
chmod 644 *.flac
......@@ -456,13 +469,26 @@ if [ "$command" = "uptn" ]; then
{
while read file
do
# Remove .flac and leading disc number
# Remove .flac and leading disc number (if present)
tag_tracknumber=`echo ${file%.flac} | sed 's/^[1-9] - //'`
# Get the track number without leading 0
tag_tracknumber=${tag_tracknumber%% - *}
tag_tracknumber=${tag_tracknumber#0}
printf "$file: \033[7m$tag_tracknumber\033[0m\n"
if [ "$multi_disc" = "1" ]; then
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`
fi
metaflac --set-tag="DISCNUMBER=$tag_discnumber" "$file"
metaflac --set-tag="DISCTOTAL=$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"
else
printf "track \033[7m$tag_tracknumber\033[0m / \033[7m$tag_tracktotal\033[0m: $file\n"
fi
metaflac --set-tag="TRACKNUMBER=$tag_tracknumber" "$file"
metaflac --set-tag="TRACKTOTAL=$tag_tracktotal" "$file"
done
}
# Set read-only permission
......@@ -471,6 +497,8 @@ if [ "$command" = "uptn" ]; then
# MP3 files
elif [ "$mp3_files" != "" ]; then
print_header "Set track numbers from filename in all tracks"
# Set read-write permission
chmod 644 *.mp3
......
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