Rename files with numbers
Micah Elliott
mde at micah.elliott.name
Mon Oct 31 13:40:54 EST 2005
On Oct 31, dudufigueiredo at gmail.com wrote:
> I have one folder containing mp3 files, the folder is:
> C:\My Shared Folder\Rubber Soul
>
> And the files are:
> 03 you won't see me.mp3
> .
>
> I'm trying to rename files to:
> The Beatles - You Won't See Me.mp3
> .
My first suggestion is that you make better changes while you're
taking the effort to rename. I.e., don't use spaces or apostrophes
(or other shell-unfriendly characters) in file names (though some
might disagree with me on this religious issue). So for your case a
more parse-able/useful translation might be:
The_Beatles_-_You_Wont_See_Me.mp3
> So I need to change the file number to "The Beatles -"
You'll probably want to use "re" for this. In a loop over
your glob'd files, something like:
re.sub(r'^\d\d\s', r'The Beatles - ', ...)
> and Capitalize the name.
If you avoid the apostrophe, then 'you wont see me'.title() will do
the Right Thing.
> I was trying to create a function and using glob and rename, but i
> had no sucsses... Could somebody help me please,
You should post the solution you've attempted to write if you want help
fixing it.
--
_ _ ___
|V|icah |- lliott http://micah.elliott.name mde at micah.elliott.name
" " """
More information about the Python-list
mailing list