simple problem with os.rename() parameters - path with spaces
Tom
tmm at fastmail.fm
Sat Sep 10 11:17:30 EDT 2005
Peter Hansen wrote:
> 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.
>>
>>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"
>
>
> What kind of device is drive E: ? Are you certain it allows spaces in
> filenames? Can you do the same renaming *using the same drive* at the
> command line or from Explorer?
>
> -Peter
Drive E: is removable, so I was careful to verify that that was a factor
in the problem.
Yes, I can do the same renaming, with the same drive, at the command line.
I think I put the emphasis in the wrong place in my question. This
isn't really about os.rename(). It is about putting a filename with
spaces into a string object and then using it as a parameter to an 'os'
command.
Tom.
More information about the Python-list
mailing list