On 11Dec2015 11:04, oyster <lepto.pyt...@gmail.com> wrote:
there is shutil module, but I find it limits the user heavily. For
example, I want to move 2 directories "a/scene" and "c/scene" to "d",
but there is "scene" under d already. Then shutil.move will raise
Error, "Destination path '%s' already exists" % real_dst

So is there any module, which allow me move/copy like Windows does.
for example
useableShutil.move('a/scene', 'd', overwite=True)

Surely the "subprocess" module, which would let you invoke the Windows copy command.

The reason that the stdlib doesn't offer something like that is that there are many many decisions one might make when overlaying one directory tree on another. Consult the manual entry for rsync to get a feel for how many nuances one might want in such a situation. The Window's "copy" command makes one set of choices; they may not fit many users' needs.

Instead the stdlib supports the simple "no conflicts" case (which is safe) and leaves it to others to solve harder problems, because there are many ways to "solve" those problems.

It is very easy to invoke os.walk on the "copying in" tree and compute the matching paths in the target directory, and then make your own decisions (make missing intermediate directories, overwrite existing files or only if the source is newer or whatever). BTW, if you go this route (write your own) then I suggest you give it a "no action" mode to report what it will do - that way you can check first before destroying your data.

Cheers,
Cameron Simpson <c...@zip.com.au>
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to