shutil.move has a mind of its own

Steve Holden steve at
Wed Jan 12 17:46:13 EST 2005

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 :)

AS several people have already suggested, you must have an error in the 
calling code, which wasn't included in the pasted snippet.

Also, "data" appears to be a global variable, which leaves us lacking 
some useful information.

Does the debugMess() call show the full destination path for the file?

Steve Holden     
Python Web Programming
Holden Web LLC      +1 703 861 4237  +1 800 494 3119

More information about the Python-list mailing list