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

tag-sieve: Add track/disc total in MP3 tags



Add optional information about the total number of tracks and discs in
TRCK and TPOS tags, in MP3 files.
Signed-off-by: default avatarCédric Marie <cedric.marie@openmailbox.org>
parent 9e3a7c92
......@@ -508,8 +508,11 @@ if [ "$command" = "uptn" ]; then
if [ "${first_file%% - *}" = "1" ]; then
multi_disc=1
last_file=`ls -1r *.mp3 | grep -m 1 mp3`
tag_disctotal=${last_file%% - *}
print_header "Set track/disc numbers from filename in all tracks"
else
tag_tracktotal=`ls -1 *.mp3 | grep -c mp3`
print_header "Set track numbers from filename in all tracks"
fi
......@@ -525,14 +528,19 @@ if [ "$command" = "uptn" ]; then
# Get the track number without leading 0
tag_tracknumber=${tag_tracknumber%% - *}
tag_tracknumber=${tag_tracknumber#0}
id3v2 --track "$tag_tracknumber" "$file"
if [ "$multi_disc" = "1" ]; then
tag_discnumber=${file%% - *}
id3v2 --TPOS "$tag_discnumber" "$file"
printf "track \033[7m$tag_tracknumber\033[0m, disc \033[7m$tag_discnumber\033[0m: $file\n"
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`
fi
id3v2 --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"
else
printf "track \033[7m$tag_tracknumber\033[0m: $file\n"
printf "track \033[7m$tag_tracknumber\033[0m / \033[7m$tag_tracktotal\033[0m: $file\n"
fi
id3v2 --track "$tag_tracknumber/$tag_tracktotal" "$file"
done
}
# Set read-only permission
......
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