copying file with like tree structure
by Skaperen from LinuxQuestions.org on (#58VW8)
before i create something of my own to do this (it will be a largish project done mostly in Python), i'd like to know if there are any tools or scripts or programs around that can copy a file from tree 1 to tree 2 when a path is given of a file within tree 1 and retain its relative path in the 2nd tree. that is, if i call it copytree, then this command:
Code:copytree treeone treetwo foo/bar/source/main.cwill create treetwo/foo, treetwo/foo/bar, treetwo/foo/bar/source, and copy file main.c from treeone/foo/bar/source to treetwo/foo/bar/source. if thsoe directories already exit, such as from a previous file being copied, then it will just use what is there (not an error). the idea is that i want to create an archive of my big messy home directory, one or a few files at a time,, while retaining the original structure as it is done.


Code:copytree treeone treetwo foo/bar/source/main.cwill create treetwo/foo, treetwo/foo/bar, treetwo/foo/bar/source, and copy file main.c from treeone/foo/bar/source to treetwo/foo/bar/source. if thsoe directories already exit, such as from a previous file being copied, then it will just use what is there (not an error). the idea is that i want to create an archive of my big messy home directory, one or a few files at a time,, while retaining the original structure as it is done.