In terminal, merging multiple folders into one.

Posted by Josh Pinter on Stack Overflow See other posts from Stack Overflow or by Josh Pinter
Published on 2010-04-26T16:15:32Z Indexed on 2010/04/26 16:23 UTC
Read the original article Hit count: 299

Filed under:
|
|
|
|

I have a backup directory created by WDBackup (western digital external HD backup util) that contains a directory for each day that it backed up and the incremental contents of just what was backed up.

So the hierarchy looks like this:

20100101
  My Documents
    Letter1.doc
  My Music
    Best Songs Every
      First Songs.mp3
    My song.mp3 # modified 20100101
20100102
  My Documents
    Important Docs
      Taxes.doc
  My Music
    My Song.mp3 # modified 20100102

...etc...

Only what has changed is backed up and the first backup that was ever made contains all the files selected for backup.

What I'm trying to do now is incrementally copy, while keeping the folder structure, from oldest to newest, each of these dated folders into a 'merged' folder so that it overrides the older content and keeps the new stuff.

As an example, if just using these two example folders, the final merged folder would look like this:

Merged
  My Documents
    Important Docs
      Taxes.doc
    Letter1.doc
  My Music
    Best Songs Every
      First Songs.mp3
    My Song.mp3 # modified 20100102

Hope that makes sense.

Thanks,

Josh

© Stack Overflow or respective owner

Related posts about unix

Related posts about command-line