A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2005-September/339196.html below:

simple problem with os.rename() parameters

simple problem with os.rename() parameters - path with spacesTom tmm at fastmail.fm
Thu Sep 8 12:10:02 EDT 2005
I'm having a problem using a path with spaces as a parameter to 
os.rename() in a program on WinXP.

This works fine at the command line (where the folder "c:\aa bb" exists)

 > os.rename( "c\aa bb", "c:\cc dd" );
 >

But, I can't get it to work in my program, eg.

print SrcDir
print NewDir
os.rename( SrcDir, NewDir );

when I run this I get something like this:

"e:\\music\\Joni Mitchell\\ogg-8"
"e:\\music.ogg\\Joni Mitchell\\ogg-8"

Traceback (most recent call last):
   File "E:\Music\MoveMusic.py", line 64, in ?
     main();
...
   File "E:\Music\MoveMusic.py", line 49, in Visit
     os.mkdir( NewDir );
OSError: [Errno 22] Invalid argument: '"e:\\music.ogg\\Joni 
Mitchell\\ogg-8"'

I've tried different combinations of single backslash vs. double 
backslash, and quoted vs. non-quoted, but it always fails.

The problem is not specific to os.rename.  If I instead use mkdir( 
SrcDir ) I get the same problem.

Thanks,
Tom.


More information about the Python-list mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4