📜 ⬆️ ⬇️

"Right" music. Or how to clean up your MP3 collection


Motives

Inspired by habratopikom .

Prehistory

In October 2008, I bought an iPhone 3G and, until this summer, I used it as an mp3 player. The need to download music to a smartphone using iTunes, at first, I was pretty annoying. But, as it turned out much later, perhaps this is what saved me a headache with converting the tags written in Cyrillic. I simply did not hesitate to add albums from my collection to the “tuna” and always guaranteed to receive tracks on the phone without “krakozyabr”. Conveniently. But everything comes to an end.

I "took" the iPhone. The event is sad, I already got used to the smartphone very much and could not survive even 4 weeks without it. I could not wait for an iPhone 4 to appear in retail (it was completely unclear when it would appear in Russia and whether it would appear at all), resellers did not like the price tag, and I had to choose from what was in stores. My choice fell on the Samsung Galaxy S. I liked the device. Unaccustomed, after iOS, some things were annoying, there were pluses, there were minuses, but on the whole, everything was fine with me.

It is time to “charge” the new device with my favorite tracks and then ... Surprise! Most of my collection was not ready to move to Androyd. Yes, precisely: these very "krakozyabry" innumerable hordes began to emerge into the world. Along the way, another unpleasantness was discovered - a fair amount of albums have no tags at all! Apparently, either the iPod application on the iPhone or iTunes, in addition to tags, used file names. Moreover, the tracks were played not at all in the order I was used to! There was only one thing to do - bring your collection to full order: change the encoding of tags to UTF-8, add tags where they were missing and consistently rename all files, sorting them into directories in a strict hierarchy.
')
We are ours, we will build a new world

I decided to start with a total reorganization of the collection. What for? It will be clear later. I proceeded from the fact that, for the convenience of mass processing, the entire collection should be in one place. I have this “Music” folder on one of the most capacious hard drives. Next in the hierarchy, logically, there should have been folders named according to the genre, but I abandoned this idea. Inside the folder “Music” I created folders with names corresponding to the names of the performers or the names of the groups: “Cinema” , “Time Machine” , “A. Rosenbaum " , " M. Shufutinsky ” , “ Depeche mode ” , etc. But inside these folders there were folders with album names, and I started their names, if possible, with the year of release: “ 1984 - Head of Kamchatka ” , “ 1986 - Black Celebration ” and everything in the same spirit. Finally, the files themselves were already in their folders. Wikipedia articles with the discographies of my favorite bands and performers helped a lot. Soon my entire collection was laid out "on the shelves."

Convert to UTF-8

It is obvious that the problems of "cracking" were caused by the fact that Cyrillic tags were written in CP1251 encoding. The roots of this "good" grow from the total dominance of Windows. But the XXI century is already in the courtyard and the UTF-8 encoding is being used everywhere, therefore translating the tags of the entire collection to UTF-8 should save us from various “surprises” forever - whatever we use to play music: an mp3 player, smartphone or media player under Linux, Mac OS or Windows. A short googling allowed me to find the most appropriate way for me to massively convert tags into the proper encoding. All I had to do was install the python-mutagen package (I have Debian, you may have a package with a different name), which provides a utility (or rather a script written in Python) mid3iconv . After that, I only have in each of the catalogs with albums (it's more convenient for me, but nothing prevented me from doing this in the “Music” catalog) to execute the command:

find . -iname '*.mp3' -print0 | xargs -0 mid3iconv -eCP1251 --remove-v1

It recursively finds files with the mp3 extension, using tags encoded in CP1251, writes id3 version 2 tags in UTF-8 encoding, and deletes version 1 tags. Very quickly I processed my entire collection and all tags (where they were) were transferred to UTF-8 . It remains a small matter: add tags where they were not and rename and sort the files I need. But what? The answer was again found in Google: EasyTag .

Fill in the missing tags

The most difficult case is not only the complete absence of any tags, but also the names of files like “track 01.mp3”. In this case, there are only two options: either fill all the tags manually and then rename the files based on them, or throw out this garbage and buy the download on the Web. If your files are named according to the name of the composition, or vice versa, the tags are full. but the files are nameless - all is not lost. EasyTag allows you to conveniently handle all files in a folder in one fell swoop. This is where the directory hierarchy built earlier comes in handy, since it allows you to use the file path and name in the filters, parsing its elements and filling out the corresponding fields in the id3 tag. I recommend starting with settings:



It is more convenient to process files by album. Go to the folder with the album compositions - the program will scan the tags of all files and show them in the General tab in the ID3 Tag section. If the tags are not filled, the picture will be as in the screenshot.



Since within the album the files have all the tags, with the exception of two (the name of the song and the track number), will be the same - we can safely select all the files and, filling in the "year" field, click on the checkbox next to it. And all files will have this tag.



We do the same with other fields: “performer”, “album”, “genre”, etc.



But you can make it even easier - using the "Tag Scanner and file names." It is called by pressing a button in the form of a green leaf with a bent corner. To fill tags for selected files, select the "Fill tag" action from the "Scanner" list. Then, using the variables specified in the tooltip, we select the necessary tags from the full path (it was not a waste of time to restore order!) And the file name. Click on the already familiar button in the form of a green leaf, but already in the scanner window itself - the tags are filled.



Having finished work with the album, we save the changes made by pressing the “diskette” in the toolbar.



In the dialogue, put the "Repeat action for the remaining files" and click "Yes."



If we have unnamed files (something like “track 01.mp3” or even “01.mp3”), but the tags are full, the scanner allows you to rename the files according to our wishes. Just select the action “Rename file and directory” from the “Scanner” list, specify the template for the file name and click on the “green leaf” again.



You probably noticed that in my collection all files begin with numbers with a track number. What for? It's very simple - I like it when the tracks go in the right order, but various mp3-players build playlists as God puts on the soul. Some of them take the basis of file names in alphabetical order, some read the track number from the file. Renaming the files in this way, I got rid of this small problem forever.

Finally, I’ll talk about another mode of operation of the scanner - “Process fields”. With it, you can replace the underscore tags with spaces in the fields, change the case of letters, capitalize the first letters and much more.



Conclusion

The result of all this fuss was that wherever I downloaded my music collection, be it a Chinese player-whistle, a smartphone with an android, or qmmp / rythmbox / amarok (underline / add), I am guaranteed to get playback in the "correct" order and read by any device / program tags. What do you want! eight)

PS: Thanks to the authors EasyTag for a cool program!

Source: https://habr.com/ru/post/110634/


All Articles