I'm trying to overwrite a directory with another directory that contains the same files. I've tried using distutils.dir_util.copy_tree(src, dst) but it tried to make a directory for dst instead. The objective is to overwrite the directory and its contents silently. Is there any other way to do so?
views:
62answers:
2
+1
A:
Edit: This rigamarole is apparently not necessary; see the OP's answer for the reason.
You'll probably want to first rename the destination directory to something else. If that goes okay, then copy the source directory to the original name of the destination directory. Then, if that worked, delete the destination directory from its new location.
You should first create a temporary directory into which to move the destination directory using tempfile.mkdtemp
.
intuited
2010-10-06 03:26:20
A:
oops... Turns out that distutils.dir_util.copy_tree(src, dst)
works.
It's just that I got my directory path from environment variables and '\n' was stuck at the back of my path.
Adding in a .strip()
to my path variable solved the problem.
BiX
2010-10-06 03:45:57