Merge two directories together
howe.steven at gmail.com
Fri Apr 16 19:43:47 CEST 2010
Think about using the subprocess module. There are calls made just for
your. Notably (using command pydoc subprrocess.call) :
subprocess.call = call(*popenargs, **kwargs)
Run command with arguments. Wait for command to complete, then
return the returncode attribute.
The arguments are the same as for the Popen constructor. Example:
retcode = call(["ls", "-l"])
On 04/16/2010 06:48 AM, Keith Hughitt wrote:
> Suppose you have two file-trees with common sub-directories but
> different files that you want to merge together, e.g.
> You can easily merge the directories in Linux using the "cp" command:
> cp -r test/* test2/
> While Python provides some helpful methods for moving files and
> directories around (shutil.move, shutil.copytree, etc), none of them
> seem to be able to merge two directories.
> I've looked around some on Google for an alternative to calling cp
> directly, but so far no luck.
> Any ideas?
More information about the Python-list