shell上からmp3ファイルのid3tagを編集する

多くのmp3ファイルのid3tagを一括で編集したい場合、shell上から行った方が簡単である。そこでpythonのパッケージをインストールする。

sudo pip install mutagen

tagの編集は以下のコマンドを実行

Usage: mid3v2 [OPTION] [FILE]...

Mutagen-based replacement for id3lib's id3v2.

Options:
  --version             show program's version number and exit
  -h, --help            show this help message and exit
  -v, --verbose         be verbose
  -q, --quiet           be quiet (the default)
  -e, --escape          enable interpretation of backslash escapes
  -f, --list-frames     Display all possible frames for ID3v2.3 / ID3v2.4
  --list-frames-v2.2    Display all possible frames for ID3v2.2
  -L, --list-genres     Lists all ID3v1 genres
  -l, --list            Lists the tag(s) on the open(s)
  --list-raw            Lists the tag(s) on the open(s) in Python format
  -d, --delete-v2       Deletes ID3v2 tags
  -s, --delete-v1       Deletes ID3v1 tags
  -D, --delete-all      Deletes ID3v1 and ID3v2 tags
  --delete-frames=FID1,FID2,...
                        Delete the given frames
  -C, --convert         Convert tags to ID3v2.4 (any editing will do this)
  -a "ARTIST", --artist="ARTIST"
                        Set the artist information
  -A "ALBUM", --album="ALBUM"
                        Set the album title information
  -t "SONG", --song="SONG"
                        Set the song title information
  -c "DESCRIPTION":"COMMENT":"LANGUAGE", --comment="DESCRIPTION":"COMMENT":"LANGUAGE"
                        Set the comment information
  -p "FILENAME":"DESCRIPTION":"IMAGE-TYPE":"MIME-TYPE", --picture="FILENAME":"DESCRIPTION":"IMAGE-TYPE":"MIME-TYPE"
                        Set the picture
  -g "GENRE", --genre="GENRE"
                        Set the genre or genre number
  -y YYYY[-MM-DD], --year=YYYY[-MM-DD], --date=YYYY[-MM-DD]
                        Set the year/date
  -T "num/num", --track="num/num"
                        Set the track number/(optional) total tracks
You can set the value for any ID3v2 frame by using '--' and then a frame ID.
For example:
        mid3v2 --TIT3 "Monkey!" file.mp3
would set the "Subtitle/Description" frame to "Monkey!".

Any editing operation will cause the ID3 tag to be upgraded to ID3v2.4.

曲名を編集するなら

mid3v2 -t "曲の名前" foo.mp3

または

mid3v2 --TIT2 "曲の名前" foo.mp3

 任意のtagを消したいなら、

mid3v2 --delete-frames TAG名 foo.mp3(TAG名はTALBやTIT2などと指定する。)

編集結果の確認は

mid3v2 -l foo.mp3

あとはスクリプトなりで一括編集が出来る。