simple problem with os.rename() parameters - path with spaces

Peter Hansen peter at engcorp.com
Fri Sep 9 18:06:23 EDT 2005


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



More information about the Python-list mailing list