dotfiles

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

album.sh (995B)


      1 #!/bin/bash
      2 
      3 # Path to your music directory
      4 music_dir="Music/Dead_Kennedys"
      5 
      6 # Loop through all FLAC files in the directory and its subdirectories
      7 find "$music_dir" -type f -name "*.flac" | while read -r file; do
      8     # Extract the current ALBUM metadata
      9     raw_album=$(metaflac --show-tag=ALBUM "$file")
     10 
     11     # Check if the ALBUM tag exists
     12     if [[ "$raw_album" == ALBUM=* ]]; then
     13         # Extract the actual album name
     14         album_name=$(echo "$raw_album" | sed 's/^ALBUM=//')
     15 
     16         # Format the album name: capitalize the first letter of each word
     17         capitalized_album=$(echo "$album_name" | sed -e 's/\b\(.\)/\U\1/g')
     18 
     19         # Remove the original ALBUM tag
     20         metaflac --remove-tag=ALBUM "$file"
     21 
     22         # Set the new ALBUM tag with the properly capitalized name
     23         metaflac --set-tag=ALBUM="$capitalized_album" "$file"
     24 
     25         echo "Updated album metadata for: $file -> $capitalized_album"
     26     else
     27         echo "No ALBUM metadata found for: $file"
     28     fi
     29 done
     30