"/" Causing Problems With Python Function

Recommended Posts

I have been working on a script that rips music cds and encodes, and renames files using the CDDB database. I noticed the script failed when a "/" is in the name of the file I want to change the name to. Example:

>>> os.rename('track04.cdda.wav.mp3','The Rolling Stones / Intro Excerpt From Fanfare For The Common Man.mp3')
Traceback (most recent call last):
 File "<stdin>", line 1, in ?
OSError: [Errno 2] No such file or directory

if I remove the "/" the above code works just fine, so I am pretty certain the "/" is causing the problem

but I am able to use that symbol with string functions

>>> 'The Rolling Stones / Intro Excerpt From Fanfare For The Common Man.mp3 '.lower()
'the rolling stones / intro excerpt from fanfare for the common man.mp3 '

why is it failing with the os.rename() finction

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.