You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1.1 KiB

#!/bin/bash
# Ensure metaflac is installed
if ! command -v metaflac &> /dev/null; then
echo "metaflac is required but not installed. Exiting."
exit 1
fi
# Get the current directory name
album_name=$(basename "$PWD")
album_artist="Various Artists"
echo "Setting ALBUM to '$album_name', ALBUMARTIST to '$album_artist', DISCNUMBER to 1, and TRACKNUMBER incrementally."
# Initialize track counter
track_number=1
# Process each .flac file, sorted alphabetically
for flac in *.flac; do
# Skip if no flac files
[ -e "$flac" ] || continue
echo "Updating '$flac'..."
# Remove old ALBUM, ALBUMARTIST, DISCNUMBER, and TRACKNUMBER tags
metaflac --remove-tag=ALBUM --remove-tag=ALBUMARTIST --remove-tag=DISCNUMBER --remove-tag=TRACKNUMBER "$flac"
# Set new tags
metaflac --set-tag="ALBUM=$album_name" \
--set-tag="ALBUMARTIST=$album_artist" \
--set-tag="DISCNUMBER=1" \
--set-tag="TRACKNUMBER=$track_number" "$flac"
# Increment track number
track_number=$((track_number + 1))
done
echo "All files updated."