os.rename() doesn't work w/unicode??

Serge Orlov Serge.Orlov at gmail.com
Tue Feb 15 00:59:01 EST 2005


fanbanlo wrote:
> C:\MP3\001.txt -> 0.txt
> C:\MP3\01. ??? - ????(???).mp3 -> 1.mp3
>
> Traceback (most recent call last):
>   File
> "C:\Python24\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py",
> line 310, in RunScript
>     exec codeObject in __main__.__dict__
>   File "C:\MP3\!RenameNum.py", line 40, in ?
>     renameFiles(os.path.dirname(sys.argv[0]))
>   File "C:\MP3\!RenameNum.py", line 26, in renameFiles
>     os.rename(os.path.join(path, filenames), new_filename)
> OSError: [Errno 22] Invalid argument

os.rename works with unicode, you're getting this error because
question marks are not allowed in file names on Windows.

  Serge.





More information about the Python-list mailing list