shutil.move has a mind of its own

Don donald.welch at
Tue Jan 11 19:22:03 EST 2005

I don't know if this is the problem or, not, but:

shutil.move( "C:\omg.txt" , "C:\folder\subdir" )

Needs to have some special handling for the backslashes. 


shutil.move( r"C:\omg.txt" , r"C:\folder\subdir" )


shutil.move( "C:\\omg.txt" , "C:\\folder\\subdir" )


Daniel Bickett wrote:

> Hello,
> I'm writing an application in my pastime that moves files around to
> achieve various ends -- the specifics aren't particularly important.
> The shutil module was chosen as the means simply because that is what
> google and chm searches returned most often.
> My problem has to do with shutil.move actually putting the files where
> I ask it to. Citing code wouldn't serve any purpose, because I am
> using the function in the most straight forward manner, ex:
>     shutil.move( "C:\omg.txt" , "C:\folder\subdir" )
> In my script, rather than a file being moved to the desired location,
> it is, rather, moved to the current working directory (in this case,
> my desktop -- without any exceptions, mind you). As it happens, the
> desired locations are system folders (running windows xp, the folders
> To see if this factor was causing the problem, I tried it using the
> interpreter, and found it to be flawless.
> My question boils down to this: What factors could possibly cause
> shutil.move to fail to move a file to the desired location, choosing
> instead to place it in the cwd (without raising any exceptions)?
> Thank you for your time,
> Daniel Bickett
> P.S. I know I said I didn't need to post code, but I will anyway. You
> never know :)

More information about the Python-list mailing list