Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

for a long time I dream to have a songs lastfm tags in my music library, so I can use them to quickly generate playlists.

There used to be a way to do that in amarok 1.4, but it never was stable.

Than there is MusicBrainz Picard's lastfm/lastfmplus plugin. It is partially fine, but I cannot manage to make it look ONLY for the lastfm tags and put them into comments/genre/whatever but it always hast to tag everything. And it isn't particularly good with it, especially with small bands, songs without album etc.

My music library is rather well organised. Most of the tags are correct. I also have quite some songs without an album. And I don't want it to find the albums for those songs, since it'd mess up my album view. So it must not touch the fields track name, track number, artist and album. All I want is that the most popular lastfm tags get into the genre or comments tag of the mp3, separated by semicolons, commas or whatever.

I think I remember a script that did this job, but I cannot find.

Does anybody know if there is anything like this? Would it be to hard to write this, for example as Banshee plugin?

Thank you

share|improve this question
up vote 5 down vote accepted

I cooked one Python script quickly. You can review it here: or download from here:

As I understand your library is in MP3 format, so I used ID3 tagger. Script fetches top-tags and puts them in COMMENT tag.
If you ask me, although "TopTags" are more meaningful then "TrackTags" they can consist lots of garbage

Script uses Standard Python Library, except for module that writes tags - eyeD3 (sudo apt-get install python-eyed3)

Example usage (parse all files in current folder):

$ for f in *.mp3 ; do python "$f" ; done

Similar bash line can crawl through all subfolders also.

Hope it's useful :)

share|improve this answer
Thank you! I will try it as soon as I have some time, but this is exactly the kind of answer I was looking for. I started to manually make my tags and it's quite a lot of work. Thanks! – Meng Tian Aug 24 '11 at 8:56
+1 for fast food :) – theTuxRacer Aug 24 '11 at 11:04
I've made some modifications to this so that just the first five tags are used and it also sets the Genre: – Arthur Dec 13 '15 at 16:46

The bash script noted above is doing the trick for me - but how would I use it to automatically go through my subdirectories recursively? My subdirectories and files also have spaces in them - so how would I script it when I have spaces in file names?

I searched around, and wrapped it with this:

mp3_files=$(find "${current_directory}" -type f -iname "*.mp3")
# Need to change IFS or files with filenames containing spaces will not
# be handled correctly by for loop
for mp3_file in ${mp3_files}; do 
   python /home/bruce/ "$f" ; 

But I'm thinking that isn't quite it.

share|improve this answer
Line 7 should be python /home/bruce/ "$mp3_file" ; – Arthur Dec 13 '15 at 14:10

Make the script executable and run it like this:


IFS=$(echo -en "\n\b")

for f in $(find ./ -type f -iname "*.mp3")
    # or use this : python $HOME/bin/ "$f" ;

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.