大家好,希望我能找到与音乐相关的问题的答案。我从 PC 切换到 Ubuntu,并且过去曾运行过 iTunes。
我有很多 CD 音乐,但我将它们一张一张地加载到系统中。
问题是,虽然文件仍然存在,但它们被命名为无用的名称,例如“AVHB”、“GCDF”或其他名称。我可以在 Rhythmbox 和我的 Android 手机上播放这些文件,并且会出现正确的名称,但文件名不是文件的准确描述符。
所以我的问题是:如何使用 python 或其他程序创建脚本,以便通过 CODEC 运行这些文件并正确重命名这些文件?播放器有转换功能,但我似乎无法跨越这个鸿沟。
谢谢!
答案1
您可以使用id3ren
ID3Tag 文件重命名器。该应用程序位于存储库中,因此可以轻松安装。它应该也适用于.m4a
文件。
sudo apt-get install id3ren
要使用它,请转到音乐所在的文件夹,最好是实际包含要重命名的音乐的文件夹。然后,您可以使用 提供的模板重命名id3ren
。模板选项如下:
-template=TEMPLATE
Use TEMPLATE as the basis for renaming files. The default tem‐
plate used is '[%a]-[%s].mp3'. Identifiers that can be used in
the template are:
%a - Artist name
%c - Comment
%s - Song name
%t - Album title
%n - Track Number
%y - Year
%g - Genre
使用我的系统中一个我知道命名错误的目录,我们可以在运行这些文件之前看到它们id3ren
:
$ ls -l *.mp3
-rwxrwxrwx 1 root root 3851479 Jul 10 20:31 01 - Track 1.mp3
-rwxrwxrwx 1 root root 3726796 Jul 10 20:31 02 - Track 2.mp3
-rwxrwxrwx 1 root root 5001982 Jul 10 20:31 03 - Track 3.mp3
-rwxrwxrwx 1 root root 3111721 Jul 10 20:32 04 - Track 4.mp3
-rwxrwxrwx 1 root root 4680892 Jul 10 20:32 05 - Track 5.mp3
-rwxrwxrwx 1 root root 4504918 Jul 10 20:32 06 - Track 6.mp3
-rwxrwxrwx 1 root root 5135839 Jul 10 20:32 07 - Track 7.mp3
-rwxrwxrwx 1 root root 5397715 Jul 10 20:32 08 - Track 8.mp3
-rwxrwxrwx 1 root root 3229732 Jul 10 20:32 09 - Track 9.mp3
-rwxrwxrwx 1 root root 3760156 Jul 10 20:32 10 - Track 10.mp3
现在,id3ren
在文件夹上运行模板选项以Track Number - Song Name.mp3
使用该文件夹中的所有mp3
文件(*.mp3)
:
$ id3ren -template='%n - %s.mp3' *.mp3
01 - Track 1.mp3 => 01 - Your Song.mp3
02 - Track 2.mp3 => 02 - Daniel.mp3
03 - Track 3.mp3 => 03 - Honky Cat.mp3
04 - Track 4.mp3 => 04 - Goodbye Yellow Brick Road.mp3
05 - Track 5.mp3 => 05 - Saturday Nights Alright.mp3
06 - Track 6.mp3 => 06 - Rocket Man.mp3
07 - Track 7.mp3 => 07 - Benny and the Jets.mp3
08 - Track 8.mp3 => 08 - Dont Let the Sun Go Down on Me.mp3
09 - Track 9.mp3 => 09 - Border Song.mp3
10 - Track 10.mp3 => 10 - Crocodile Rock.mp3
Processed: 10 Failed: 0 Total: 10
正如我们现在所看到的,该文件夹中的文件已重命名为与文件本身包含的 ID3Tag 匹配.mp3
:
$ ls -l *.mp3
-rwxrwxrwx 1 root root 3851479 Oct 24 15:39 01 - Your Song.mp3
-rwxrwxrwx 1 root root 3726796 Oct 24 15:39 02 - Daniel.mp3
-rwxrwxrwx 1 root root 5001982 Oct 24 15:39 03 - Honky Cat.mp3
-rwxrwxrwx 1 root root 3111721 Oct 24 15:39 04 - Goodbye Yellow Brick Road.mp3
-rwxrwxrwx 1 root root 4680892 Oct 24 15:39 05 - Saturday Nights Alright.mp3
-rwxrwxrwx 1 root root 4504918 Oct 24 15:39 06 - Rocket Man.mp3
-rwxrwxrwx 1 root root 5135839 Oct 24 15:39 07 - Benny and the Jets.mp3
-rwxrwxrwx 1 root root 5397715 Oct 24 15:39 08 - Dont Let the Sun Go Down on Me.mp3
-rwxrwxrwx 1 root root 3229732 Oct 24 15:39 09 - Border Song.mp3
-rwxrwxrwx 1 root root 3760156 Oct 24 15:39 10 - Crocodile Rock.mp3
编辑:还使用艺术家名称进行批量重命名。只要 ID3 标签中的艺术家标签正确,此方法即可奏效:
这首歌由 [艺术家] - [曲目] - [名字] 演唱
$ id3ren -template='%a - %n - %s.mp3' *.mp3
01 - Your Song.mp3 => Elton John - 01 - Your Song.mp3
02 - Daniel.mp3 => Elton John - 02 - Daniel.mp3
03 - Honky Cat.mp3 => Elton John - 03 - Honky Cat.mp3
04 - Goodbye Yellow Brick Road.mp3 => Elton John - 04 - Goodbye Yellow Brick Road.mp3
05 - Saturday Nights Alright.mp3 => Elton John - 05 - Saturday Nights Alright.mp3
06 - Rocket Man.mp3 => Elton John - 06 - Rocket Man.mp3
07 - Benny and the Jets.mp3 => Elton John - 07 - Benny and the Jets.mp3
08 - Dont Let the Sun Go Down on Me.mp3 => Elton John - 08 - Dont Let the Sun Go Down on Me.mp3
09 - Border Song.mp3 => Elton John - 09 - Border Song.mp3
10 - Crocodile Rock.mp3 => Elton John - 10 - Crocodile Rock.mp3
Processed: 10 Failed: 0 Total: 10
这首歌曲由 [曲目] - [艺术家] - [姓名] 演唱。
$ id3ren -template='%n - %a - %s.mp3' *.mp3
Elton John - 01 - Your Song.mp3 => 01 - Elton John - Your Song.mp3
Elton John - 02 - Daniel.mp3 => 02 - Elton John - Daniel.mp3
Elton John - 03 - Honky Cat.mp3 => 03 - Elton John - Honky Cat.mp3
Elton John - 04 - Goodbye Yellow Brick Road.mp3 => 04 - Elton John - Goodbye Yellow Brick Road.mp3
Elton John - 05 - Saturday Nights Alright.mp3 => 05 - Elton John - Saturday Nights Alright.mp3
Elton John - 06 - Rocket Man.mp3 => 06 - Elton John - Rocket Man.mp3
Elton John - 07 - Benny and the Jets.mp3 => 07 - Elton John - Benny and the Jets.mp3
Elton John - 08 - Dont Let the Sun Go Down on Me.mp3 => 08 - Elton John - Dont Let the Sun Go Down on Me.mp3
Elton John - 09 - Border Song.mp3 => 09 - Elton John - Border Song.mp3
Elton John - 10 - Crocodile Rock.mp3 => 10 - Elton John - Crocodile Rock.mp3
Processed: 10 Failed: 0 Total: 10
希望这可以帮助!