Authors Top

If you have a few years of experience in the Linux ecosystem, and you’re interested in sharing that experience with the community, have a look at our Contribution Guidelines.

1. Introduction

Most of us use streaming platforms to listen to music these days. But, we might still have some MP3 files lying around in our collection, for nostalgia’s sake, or just in case we need music when offline. We may even fancy playing them on an old MP3 player device that still works.

In any case, it’s useful to know how to edit the tags on an MP3 file in order to keep our collection organized. These tags are known as ID3 tags and are designed to store metadata about the music file such as track title, artist, album, etc. in the file itself. In this tutorial, we’ll look at various tools that help us edit these ID3 tags.

2. id3v2

The first tool we’ll be looking at is the id3v2 tool. It can be used to view the ID3 tags on an MP3 file. In addition, it can make simple edits to the metadata.

2.1. Installation

id3v2 may not be installed by default, but here’s how Ubuntu users can install it:

$ sudo apt install id3v2

For other distributions, we’ll have to use the appropriate package manager and package name. Once it’s installed, we can run the command with the -h flag to view its help section:

$ id3v2 -h

From the help output, we can observe that this command can be used to view and edit the metadata such as artist, album, track number, etc.

2.2. Editing Tags

To add or change a particular field in the metadata, we have to run the command with the appropriate flag and the new value. For instance, we’ve to use the -a flag to change the artist’s name. This must be followed by the name/path to the MP3 file. Let’s try this:

$ id3v2 -a "My Favorite Artist" my_music_file.mp3

Once we’ve made the edit, we can use the id3v2 command again to check the new metadata:

$ id3v2 -l my_music_file.mp3
id3v1 tag info for my_music_file.mp3:
Title  :                                 Artist: My Favorite Artist            
Album  :                                 Year:     , Genre: Unknown (255)
Comment:                                 Track: 0
id3v2 tag info for my_music_file.mp3:
TPE1 (Lead performer(s)/Soloist(s)): My Favorite Artist

We see that the artist name we supplied has been updated. We can also use multiple flags in the command to update multiple fields at once:

$ id3v2 -t "My Favorite Song" -A "My Favorite Album" -T 1 -y 2002 my_music_file.mp3

$ id3v2 -l my_music_file.mp3
id3v1 tag info for my_music_file.mp3:
Title  : My Favorite Song                Artist: My Favorite Artist            
Album  : My Favorite Album               Year: 2002, Genre: Unknown (255)
Comment:                                 Track: 1
id3v2 tag info for my_music_file.mp3:
TPE1 (Lead performer(s)/Soloist(s)): My Favorite Artist
TIT2 (Title/songname/content description): My Favorite Song
TALB (Album/Movie/Show title): My Favorite Album
TRCK (Track number/Position in set): 1
TYER (Year): 2002

In the first command above, we used multiple flags to update multiple fields, i.e., -t for the track title, -A for the album name, -T for the track number, and -y for the recording year.  Later, by running the command with the list flag (-l), we see that all the field updates we made are reflected in the metadata.

3. eyeD3

eyeD3 is a Python-based tool that we can use to display and edit ID3 tags. It’s available both as a command line tool and as a Python library to be used in Python programs. We’ll look at how to use it from the command line.

3.1. Installing eyeD3

We can install eyeD3 using the pip command that’s commonly used to install Python packages:

$ pip install eyeD3

Once it finishes installing, we can run the command with the –about flag to ensure it’s installed:

$ eyeD3 --about
0.9.7 ...(more output)

Now, the tool’s ready for use.

3.2. Viewing and Editing ID3 Tags

To view the existing ID3 tags of an MP3 file, we can run the eyeD3 command with the file path as a positional argument:

$ eyeD3 my_music_file.mp3 
/home/karthik/music/my_music_file.mp3                                                [ 6.62 MB ]
-------------------------------------------------------------------------------------------------
Time: 05:00	MPEG1, Layer III	[ ~185 kb/s @ 44100 Hz - Stereo ]
-------------------------------------------------------------------------------------------------
ID3 v2.3:
title: My Favorite Song
artist: My Favorite Artist
album: My Favorite Album
recording date: 2002
track: 1		
-------------------------------------------------------------------------------------------------

The command prints the metadata we had set using the id3v2 command earlier. Now, we can change each of these fields using the corresponding argument flags:

$ eyeD3 -a "Linkin Park" -A "Hybrid Theory" -t "In The End" -n 8 -Y 2000 my_music_file.mp3 
/home/karthik/music/my_music_file.mp3                                                [ 6.62 MB ]
-------------------------------------------------------------------------------------------------
Setting artist: Linkin Park
Setting album: Hybrid Theory
Setting title: In The End
Setting track info: (8, None)
Setting release year: 2000
Time: 05:00	MPEG1, Layer III	[ ~185 kb/s @ 44100 Hz - Stereo ]
-------------------------------------------------------------------------------------------------
ID3 v2.3:
title: In The End
artist: Linkin Park
album: Hybrid Theory
release date: 2000
original release date: 2000
recording date: 2002
track: 8		
Writing ID3 version v2.3
-------------------------------------------------------------------------------------------------

We used the flags -a for the artist’s name, -A for the album name, -t for the track title, -n for the track number, and -Y for the year. The command replaces the metadata with the new data we provided and prints the corresponding output.

We must also note that the -Y flag set the release date and original release date fields with the value 2000 when we used the eyeD3 command. On the contrary, the -y flag of the id3v2 command had set the recording date field. To change the recording date with eyeD3, we can use the –recording-date flag.

3.3. Changing Album Artwork

eyeD3 also lets us change the album artwork using the –add-image flag:

$ eyeD3 --add-image art.jpg:FRONT_COVER my_music_file.mp3
/home/karthik/music/my_music_file.mp3                                                [ 6.62 MB ]
-------------------------------------------------------------------------------------------------
Adding image art.jpg
Time: 05:00	MPEG1, Layer III	[ ~185 kb/s @ 44100 Hz - Stereo ]
-------------------------------------------------------------------------------------------------
ID3 v2.3:
title: In The End
artist: Linkin Park
album: Hybrid Theory
release date: 2000
original release date: 2000
recording date: 2002
track: 8		
FRONT_COVER Image: [Size: 186666 bytes] [Type: image/jpeg]
Description: 

Writing ID3 version v2.3
-------------------------------------------------------------------------------------------------

In addition to the path to the image, we also need to specify the TYPE of the image, which we set as FRONT_COVER. A full list of available options for the TYPE is available in the help section of eyeD3.

4. id3tool

id3tool is yet another command line utility that can help us edit the ID3 tags of an MP3 file. It’s a very lightweight and straightforward tool to use.

4.1. Installation

id3tool may not be installed by default. On Ubuntu, we can install it simply:

$ sudo apt install id3tool

The package name and the package manager may be different for other distributions. After installing, let’s run the command with the -h flag to see what it can do:

$ id3tool --help
id3tool version 1.2a
...(more output)

The help message prints all the fields that can be edited along with other useful information.

4.2. Viewing and Editing ID3 Tags

To view the tags present in an MP3 file, we simply run the id3tool command with the path to the file as a positional argument:

$ id3tool my_music_file.mp3
Filename: my_music_file.mp3
Song Title:	My Favorite Song              
Artist:		My Favorite Artist            
Album:		My Favorite Album             
Track:		1
Year:		2002

To change the tags, we can run the command with the required flags and the corresponding values:

$ id3tool -t "In The End" -a "Hybrid Theory" -r "Linkin Park" -y 2000 -c 8 my_music_file.mp3

$ id3tool my_music_file.mp3
Filename: my_music_file.mp3
Song Title:	In The End                    
Artist:		Linkin Park                   
Album:		Hybrid Theory                 
Track:		8
Year:		2000

In the first command, we used the flags -t-a-r-y, and -c to edit the track title, album name, artist’s name, year, and track number fields respectively. Later, we ran the view command to verify that the change has occurred.

5. Conclusion

In this article, we looked at different ways to edit the ID3 tags of an MP3 file.

id3v2 and id3tool are very simple and straightforward to install and use. However, eyeD3 requires Python and offers us more options. For instance, we can change the album art. Further, we can use these tools with Bash scripts to automate and programmatically perform their functions.

Authors Bottom

If you have a few years of experience in the Linux ecosystem, and you’re interested in sharing that experience with the community, have a look at our Contribution Guidelines.

Comments are closed on this article!