This is a discussion on A script renaming mp3 files according to their track number within the Gentoo Linux Support forums, part of the Unix Operating Systems category; --> Hello Newsgroup, I just got a new portable mp3 player and I really like listening to music everywhere I ...
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hello Newsgroup, I just got a new portable mp3 player and I really like listening to music everywhere I am. When I ripped the mp3 files (I do really own all of those CDs but I don't like using CDs due to the risk of scratching) I made my ripping program naming them this way: Pink Floyd - High Hopes.mp3 or in general: Artist - Track title.mp3 The mp3 player is not able to handle track lists or recognize the track numbers which are stored as ID3 tags. Is anybody of you able and likely to write a little shell script or anything like that which would rename the tracks beginning with the track number? Example: 09 Pink Floyd - High Hopes.mp3 or in general: ## Artist - Track title.mp3 This would help my very much because I really don't want to rip all of my CDs another time. It's not that I buy all this senseless music or rip every single track I can get but time by time I got a nice collection of really good music -- it stills exists;-) Grateful for any advice and help Daniel Böhmer, Germany |
| |||
| On 2006-06-19, Daniel Böhmer wrote: > Is anybody of you able and likely to write a little shell script or > anything like that which would rename the tracks beginning with the > track number? Example: > > 09 Pink Floyd - High Hopes.mp3 > or in general: ## Artist - Track title.mp3 Not sure I can really help, but isn't that naming scheme going to be a pain when it comes to sorting? For my own collection I decided that the following would be a lot better: Artist-Album-Track-Title.extension With all non-alphanummeric and non-ascii characters removed or converted so something more filesystem friendly. Eg. spaces converted to underscores, and various Scandinavian characters changed to more internationally readable characters (æ->ae, ø->oe, å->aa, etc). In total, this means that even if I have to put all of the files in the same directory (not by Artist/Album as I do now), on a non-ID3 compatible device, a simple alphanummeric sort by filename would still list them appropriately. With your scheme, you'd have tracks from one album mixed with tracks from other albums. -- Jesper <xyborx+usenet@xyborx.dk> "Do not meddle in the affairs of cats, for they are cunning, and you sleep with your mouth open" |
| |||
| On 19 Jun 2006 16:48:18 GMT, Jesper <xyborx+usenet@xyborx.dk> wrote: >On 2006-06-19, Daniel B?hmer wrote: >> Is anybody of you able and likely to write a little shell script or >> anything like that which would rename the tracks beginning with the >> track number? Example: >> >> 09 Pink Floyd - High Hopes.mp3 >> or in general: ## Artist - Track title.mp3 >Not sure I can really help, but isn't that naming scheme going to be a >pain when it comes to sorting? For my own collection I decided that the >following would be a lot better: >Artist-Album-Track-Title.extension >With all non-alphanummeric and non-ascii characters removed or converted >so something more filesystem friendly. Eg. spaces converted to >underscores, and various Scandinavian characters changed to more >internationally readable characters (?->ae, ?->oe, ?->aa, etc). >In total, this means that even if I have to put all of the files in the >same directory (not by Artist/Album as I do now), on a non-ID3 >compatible device, a simple alphanummeric sort by filename would still >list them appropriately. With your scheme, you'd have tracks from one >album mixed with tracks from other albums. I'm not the OP, but I put each album in it's own directory and use track numers as a track prefix so that I can be sure that they'll be played in the correct order. |
| |||
| > I'm not the OP, but I put each album in it's own directory and use > track numers as a track prefix so that I can be sure that they'll > be played in the correct order. That's exactly what I wanna do. The single files are in folders named with the title of the album. Example: root +--Pink Floyd +--The Division Bell +--Pink Floyd - High Hopes.mp3 +--Pink Floyd - Marooned.mp3 Problem here is that "High Hopes" comes before "Marooned" by alphabetical sorting but this is not the correct listing from the CD. I want to keep the files in their folders but extend their names by the track number. My mp3 player can handle folders but it's not able to sort files by track number. I hope you do now understand what the problem actually is and anybody can help me. Thanks Daniel |
| |||
| On Mon, 19 Jun 2006 20:56:58 +0200, Daniel Böhmer <boehmerdaniel@web.de> wrote: >> I'm not the OP, but I put each album in it's own directory and use >> track numers as a track prefix so that I can be sure that they'll >> be played in the correct order. >That's exactly what I wanna do. The single files are in folders named >with the title of the album. Example: >root >+--Pink Floyd > +--The Division Bell > +--Pink Floyd - High Hopes.mp3 > +--Pink Floyd - Marooned.mp3 >Problem here is that "High Hopes" comes before "Marooned" by >alphabetical sorting but this is not the correct listing from the CD. I >want to keep the files in their folders but extend their names by the >track number. My mp3 player can handle folders but it's not able to sort >files by track number. >I hope you do now understand what the problem actually is and anybody >can help me. I already had a hard drive walkman that put the tracks in directories in folders named by the genre. The directories were named artist_album. I used a python script to scan the entire tree and in each folder put numerical prefixes on each track, providing there wasn't already a prefix. It's a work in progress where I'm going to reset the ID3 tracks and eventually move away from the artist_album directories. Here it is, as is. You should be able to figure out how to modify it for your own use. Currently the parts that change the id3 fields and do the rename are commented out. Uncomment them out when the debugging printouts are correct. #! /usr/bin/env python import os, sys, string if len(sys.argv) < 2: sys.exit( "usage scan <topdir>" ) top=sys.argv[1] for genre in os.listdir(top): try: for artist_album in os.listdir(top + "/" + genre): underscore = string.find(artist_album, "_") artist=artist_album[:underscore] album=artist_album[underscore+1:] print artist, "/", album track=0 rename_tracknums=1 for filename in os.listdir( top+"/"+genre+"/"+artist_album ) : if ( (filename[2:4] == ". ") & (filename[1]>="0") & (filename[1]<="9") )\ | ( (filename[2] == "_") & (filename[1]>="0") & (filename[1]<="9") ): rename_tracknums=0 track=track+1 if filename[-4:] == ".mp3": song=filename[:-4] else: song=filename # os.system( 'id3v2 '+ print ( "id3v2 " + '-a"'+artist +'" '+ '-A"'+album +'" '+ '-s"'+"%2d. "%track+song +'" '+ '-t"'+str(track) +'" '+ # '-g"'+genre +'" '+ '"'+top+"/"+genre+"/"+artist_album+"/"+filename+'"' ) if rename_tracknums: # os.rename(\ print ( "rename "+ \ top+"/"+genre+"/"+artist_album+"/"+ filename +', '+ top+"/"+genre+"/"+artist_album+"/"+ "%2d. "%track+ filename ) except OSError, (errno, strerror): print "err!" pass |
| |||
| Hello, > I already had a hard drive walkman that put the tracks in directories in > folders named by the genre. The directories were named artist_album. > > I used a python script to scan the entire tree and in each folder put > numerical prefixes on each track, providing there wasn't already > a prefix. > > It's a work in progress where I'm going to reset the ID3 tracks and eventually > move away from the artist_album directories. Here it is, as is. You > should be able to figure out how to modify it for your own use. Currently the > parts that change the id3 fields and do the rename are commented out. > Uncomment them out when the debugging printouts are correct. Thank you for posting the current state of your work. Might be helpful for somebody but I cannot speak any word Python... So this script is not really helpful for me. I don't know how much work it is to change that script so that it does what I actually wanted to do. Are you able and likely to do that for me? I don't want to hustle you but it would be very friendly to help somebody who has got no clue about Python. Thanks for reading Daniel Böhmer > #! /usr/bin/env python > import os, sys, string > > > if len(sys.argv) < 2: > sys.exit( "usage scan <topdir>" ) > > top=sys.argv[1] > for genre in os.listdir(top): > try: > for artist_album in os.listdir(top + "/" + genre): > underscore = string.find(artist_album, "_") > artist=artist_album[:underscore] > album=artist_album[underscore+1:] > > print artist, "/", album > track=0 > rename_tracknums=1 > for filename in os.listdir( top+"/"+genre+"/"+artist_album ) : > if ( (filename[2:4] == ". ") & (filename[1]>="0") & (filename[1]<="9") )\ > | ( (filename[2] == "_") & (filename[1]>="0") & (filename[1]<="9") ): > rename_tracknums=0 > > track=track+1 > > if filename[-4:] == ".mp3": > song=filename[:-4] > else: > song=filename > > # os.system( 'id3v2 '+ > print ( "id3v2 " + > '-a"'+artist +'" '+ > '-A"'+album +'" '+ > '-s"'+"%2d. "%track+song +'" '+ > '-t"'+str(track) +'" '+ > # '-g"'+genre +'" '+ > '"'+top+"/"+genre+"/"+artist_album+"/"+filename+'"' ) > > if rename_tracknums: > # os.rename(\ > print ( > "rename "+ \ > top+"/"+genre+"/"+artist_album+"/"+ filename +', '+ > top+"/"+genre+"/"+artist_album+"/"+ "%2d. "%track+ filename ) > > > except OSError, (errno, strerror): > print "err!" > pass > > |
| |||
| |
| |||
| On Thu, 22 Jun 2006 20:17:06 +0200, Daniel Böhmer <boehmerdaniel@web.de> wrote: >Hello, >> I already had a hard drive walkman that put the tracks in directories in >> folders named by the genre. The directories were named artist_album. >> >> I used a python script to scan the entire tree and in each folder put >> numerical prefixes on each track, providing there wasn't already >> a prefix. >> >> It's a work in progress where I'm going to reset the ID3 tracks and eventually >> move away from the artist_album directories. Here it is, as is. You >> should be able to figure out how to modify it for your own use. Currently the >> parts that change the id3 fields and do the rename are commented out. >> Uncomment them out when the debugging printouts are correct. >Thank you for posting the current state of your work. Might be helpful >for somebody but I cannot speak any word Python... So this script is not >really helpful for me. Go to www.python.org and do an 'emerge python'. Unless you're a moron, learning and using python is a snap. Modify that script so that the debugging print statement output the correct rename operation and then ncomment out the rename operation when it looks right. Do a backup before going live, of course. |
| |||
| Daniel Böhmer wrote: > Is anybody of you able and likely to write a little shell script or > anything like that which would rename the tracks beginning with the > track number? Example: > I'd go with the 'anything like that' option here. I've tried the shell script option before, but it's too hard to pinpoint all the screwed up tags around the place. Use EasyTag (try the gtk2 version) it is seriously the best out there. I tried all the Windows ones, and some where pretty good, but EasyTag does everything. It can do batch renaming et al if you're worried that a gui one might take too long. Also, I go for <artist name>.<year>.<album>.<track #>.<track name>.<ext> so I'm not completely lost just in case all the files somehow get in the one directory. |
| ||||
| In article <slrne9dlai.hvc.xyborx+usenet@cheetah.catden.dk> , Jesper <xyborx+usenet@xyborx.dk> wrote: >... isn't that naming scheme going to be a >pain when it comes to sorting? I think this would be true of any naming scheme you might come up with. Another approach might be to consider it relationally. Keep the MP3 files themselves in one directory, with arbitrary unique names assigned (e.g. sequence numbers: 00001.mp3, 00002.mp3 ...) and then have separate sets of directories organized by artist, album, style, mood etc, which contain symlinks to the actual files. |
| Thread Tools | |
| Display Modes | |
|
|