Search code examples
shellgrepmp3eyed3

How to get an audio file's artist and set album artist equal to artist in idv2.4 tagwith eyed3


I have a large collection of audio files and for each audio file, I would like to get the value of "artist" and set "album artist" with the value I get from "artist".


Solution

    1. Install eyed3, a free command line tool that can read and write audio tags.

    2. Set all audio files tags to idv2.4:

       find . -name "*" -type f -exec eyeD3 --to-v2.4 {} \; >> ~/eyed3.log 2>&1
      
    3. Delete remaining idv1.0 tags (some players read both idv1 and idv2 and prioritize idv1 over idv2, which can sometimes make you unable to edit tags through your music player):

       find . -name "*" -type f -exec eyeD3 --remove-v1 {} \; >> ~/eyed3.log 2>&1
      
    4. Use a find command and execute shell code on each hit: read the tag, grep the artist field, remove the "artist: " string, and store the result in a variable albumartist. Then use eyed3 again to write the value from artist to the albumartist field.

       find . -name "*" -type f -exec sh -c 'albumartist=$(eyeD3 "$1" | grep -P "(?<=^artist)" | sed "s/artist\:\ //g"); eyeD3 -b "$albumartist" "$1"' sh {} \;