diff --git a/fix_album_tags_flac.sh b/fix_album_tags_flac.sh new file mode 100755 index 0000000..4579c2d --- /dev/null +++ b/fix_album_tags_flac.sh @@ -0,0 +1,52 @@ +#!/bin/bash + +# Ensure metaflac is installed +if ! command -v metaflac &> /dev/null; then + echo "metaflac is required but not installed. Exiting." + exit 1 +fi + +# Find the first .flac file +first_flac=$(find . -maxdepth 1 -type f -iname "*.flac" | sort | head -n 1) + +if [ -z "$first_flac" ]; then + echo "No FLAC files found in the current directory." + exit 1 +fi + +echo "Using '$first_flac' as source for tags." + +# Extract tags from the first FLAC +declare -A tags +for field in DATE ARTIST ORIGINALDATE ALBUMARTIST ALBUM; do + value=$(metaflac --show-tag="$field" "$first_flac" | sed "s/^$field=//") + tags[$field]="$value" +done + +# Print extracted tags +echo "Extracted tags:" +for field in "${!tags[@]}"; do + echo " $field: ${tags[$field]}" +done + +# Apply tags to other FLAC files +for flac in *.flac; do + # Skip the first FLAC file + if [ "$flac" == "$(basename "$first_flac")" ]; then + continue + fi + + echo "Tagging '$flac'..." + + for field in "${!tags[@]}"; do + # Remove existing tag + metaflac --remove-tag="$field" "$flac" + # Set new tag if it exists + if [ -n "${tags[$field]}" ]; then + metaflac --set-tag="$field=${tags[$field]}" "$flac" + fi + done +done + +echo "Tagging completed." + diff --git a/playlist_to_album.sh b/playlist_to_album.sh new file mode 100755 index 0000000..b778cf9 --- /dev/null +++ b/playlist_to_album.sh @@ -0,0 +1,39 @@ +#!/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." +