[Tutor] Renaming files

lumbricus@gmx.net lumbricus@gmx.net
Fri Jan 24 07:11:01 2003


Hi!

> At 22:50 2003-01-23 -0500, Gus Tabares wrote:
> >         I'm trying to rename files that have endings as such:
> >blah.mp3.bunchofchars . I'm trying to strip off the extra chars and just
> >have *.mp3. The files were fed into a list via the os.listdir()
> >function. The searching I've done so far has come up empty. Should I be
> >using the string module for something like this or is this a simple
> >slice operation I'm missing? Any help is greatly appreciated.
> 
> You can certainly use os.rename as J"o suggested, but I don't know
> what he wants .strip for, it removes whitespace, 

Errhm - split! I meant split

> and os.path.basename
> strips off the part of a path that precedes a file name, and you don't

Yes, I mixed that up with the Unix-command basename, which
can be used to strip off the file-suffix. 

Thanks and Greets, J"o!

-- 

-- 
sigfault

+++ GMX - Mail, Messaging & more  http://www.gmx.net +++
NEU: Mit GMX ins Internet. Rund um die Uhr für 1 ct/ Min. surfen!