Rename files with numbers

Dudu Figueiredo dudufigueiredo at gmail.com
Wed Nov 2 03:26:08 CET 2005


I wrote a simpler script based in Micah Elliott's help, it's to add the
band name to mp3 files imported with iTunes:

import glob, os

def renamer_itunes(songdir, band):
    """ Rename mp3 files imported from itunes, transformation:
        Song Name.mp3 --> Artists - Song Name.mp3
    """
    os.chdir(songdir)
    archives = glob.glob("*.mp3")
    pretties = []
    for ugly in archives:
        song, ext = os.path.splitext(ugly)
        song = song.title()
        song = band + " - " + song
        songext = song + ext
        pretties.append(songext)
    for ugly, pretty in zip(archives, pretties):
            os.rename(ugly, pretty)

Just an exercise, I'm begining in Python now...
Thanks to every one that helped me, i'll bring more questions for you.
Sorry for my bad english, i'm Brazilian... !
_________________
Eduardo Figueireredo
http://dudufigueiredo.com




More information about the Python-list mailing list