Rename files with numbers
singletoned at gmail.com
Tue Nov 1 17:57:00 CET 2005
The best free app I've found for this is MusicBrainz [www.musicbrainz.com].
This has a huge database of obsessively correct details of albums
which can be formatted in anyway you choose. It can automatically
recognise which song an MP3 is!
This is a similar script I wrote to renumber files in sequential
order. It assumes that everything before the first underscore can be
from path import path
def renumberfiles(filesdir, startnum=1):
d = path(filesdir)
x = startnum
for f in d.files():
fname = f.name.split('_', 1)
fname = str(x).zfill(2) + "_" + fname[-1]
fname = re.sub(r" ",r"_",fname)
fname = re.sub(r"__",r"_",fname)
x = x + 1
print f.name, "==>",
f.rename(f.parent + "\\" + fname)
As you can see, I use the path module rather than os.path. it's a
much more intuitive way of handling files.
On 01/11/05, Dave Benjamin <ramen at lackingtalent.com> wrote:
> On Mon, 31 Oct 2005, Micah Elliott wrote:
> > On Oct 31, Micah Elliott wrote:
> >> Now I need to go beautify my collection. :-)
> > While a fun exercise, there are probably already dozens (or
> > thousands?) of utilities in existence that do this and much more.
> Seconded. I initially considered writing a script to rename a huge pile of
> MP3 files, but halfway through, I thought, "there's *got* to be a better
> way". I found this app: http://www.softpointer.com/tr.htm
> Bought it the next day. Holy crap, what a gigantic timesaver. It looks up
> albums based on track lengths, downloads titles from freedb and Amazon,
> does ID3 tagging, renaming, moves files into separate directories... I
> busted through about 20 gigs of MP3s in three days. I kid you not.
> If this is just a fun toy Python project, don't let me discourage you, but
> if you have more than a handful of albums to rename, trust me. This
> problem has been solved.
> Here's a list of apps, including Tag&Rename, that can query freedb:
> .:[ dave benjamin: ramen/[sp00] ]:.
> \\ "who will clean out my Inbox after I'm dead[?]" - charles petzold
More information about the Python-list