Serge Orlov wrote:
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.


The filename is supposed to be in Chinese, on NTFS (WinXP). However, when i print it, they are all '???', and that caused os.rename() to break.

How to force os.walk to return a list of unicode filename?
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to