【问题标题】:Copy values of a mp3 tag to another tag for a batch of MP3 files将 mp3 标签的值复制到一批 MP3 文件的另一个标签
【发布时间】:2011-11-05 09:35:50
【问题描述】:

我有一个很大的 MP3 目录,不知何故,文件的 album 标签(或 album names)的值(对于所有这些文件,数百个)实际上是 artist 标签(或 artist names)的值反之亦然。

现在我必须互相复制这些值,以便为目录中的每个文件交换它们。或者也许我可以交换标签名称。我只希望artist 标签显示艺术家姓名,album 标签显示专辑名称。

批量编辑应该怎么做?

【问题讨论】:

  • 我需要为 ogg 和 flac 执行此操作,分别交换艺术家和标题。在 Linux 上。

标签: tags mp3 swap id3 id3-tag


【解决方案1】:

不幸的是,mp3 的标签相当棘手,但以下 python 脚本(需要库 mutagen)为 ogg 和 flac 完成了工作,至少解决了我自己的问题。

#! /usr/bin/env python
# Copyright (c) 2011 kaleissin
# MIT License, see http://www.opensource.org/licenses/mit-license.php

import mutagen
import os
import os.path

if len(sys.argv[1:]) < 1:
    print "Usage: %s <file> [file..]" % os.path.basename(__file__)

for filename in sys.argv[1:]:
    audio = mutagen.File(filename)
    audio['artist'], audio['title'] = audio['title'], audio['artist']
    audio.save()

【讨论】:

  • 我试过了,但没用。如果可行,我会在这里尝试一些修改和更新。
【解决方案2】:

ID3 Mass Tagger (https://github.com/squell/id3) 应该会有所帮助。适用于 Windows 和 Linux。

在所有 mp3 文件中交换艺术家和专辑字段。

id3 -a %l -l %a "*.mp3"

Sets keys:
-a sets the artist key
-l sets the album key

Substitutes of current key values:
%t title
%a artist
%l album title
%n track number
%y year
%g genre
%c comment field
%f file name (without path)
%p path to filename

先在样品上使用。

【讨论】:

    【解决方案3】:

    查看 python-mutagen 库中的 mid3cp tool,它完全符合您的要求。

    在 Ubuntu 下它默认不安装,但如果你只是将 this 文件的内容放入 /usr/bin 并使其可执行,它就可以工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-08-24
      • 2011-09-12
      • 1970-01-01
      • 1970-01-01
      • 2021-09-04
      • 1970-01-01
      • 1970-01-01
      • 2010-12-11
      相关资源
      最近更新 更多