simple problem with os.rename() parameters - path with spaces
tmm at fastmail.fm
Sat Sep 10 17:18:27 CEST 2005
Yes, I am sure about those things.
I've tried shutil.move and got the same result.
Forward slash? I'll give that a try and report back here if it works.
Larry Bates wrote:
> Are you sure the source directory exists and you
> have rights to rename it? Because the rename works
> for me.
> But you may want to look at shutil.move and/or
> use forward slashes (they work under Windows)
> -Larry Bates
> Tom wrote:
>>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.
>>os.rename( SrcDir, NewDir );
>>when I run this I get something like this:
>>Traceback (most recent call last):
>> File "E:\Music\MoveMusic.py", line 64, in ?
>> File "E:\Music\MoveMusic.py", line 49, in Visit
>> os.mkdir( NewDir );
>>OSError: [Errno 22] Invalid argument: '"e:\\music.ogg\\Joni
>>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.
More information about the Python-list