Moving folders with content

Laszlo Nagy gandalf at shopzeus.com
Sat Sep 15 02:36:10 EDT 2012


On 2012-09-15 06:36, jyoung79 at kc.rr.com wrote:
> Hello,
>
> I am working in both OS X Snow Leopard and Lion (10.6.8 and 10.7.4).
> I'm simply wanting to move folders (with their content) from various
> servers to the hard drive and then back to different directories on the
> servers.
>
> I want to be careful not to remove any metadata or resource forks from
> the files in the directories.  I did a bit of researching on shutil, and
> looks like it is similar to using "cp -p" and copystat(), which I believe
> will keep the resource fork, etc.
>
> Here's the code I came up with.  I'm curious if anyone finds fault with
> this, or if there's a better way to do this?
Not in this particular case, because you know that these directories are 
on different computers. But instead of rmtree+copytree, I would rather 
use shutil.move() because it will use os.rename() when the source and 
the destination are on the same filesystem. Much much faster.



More information about the Python-list mailing list