Results 1 to 3 of 3

Thread: Copying files to new destination with same realative path?

  1. #1
    Join Date
    Nov 2010
    Beans
    2

    Copying files to new destination with same realative path?

    I wonder, if a recursive copy is performed from place A, is it possible to place the copy in a new destination B that is similar in structure where the file was copied from?

    MUST CRITERIA 1: Note that only the files of specific type will be copied (here *.txt)
    MUST CRITERIA 2: Note that there is files and folders in both structure A and B that must not be copied or changed.


    From structure A:
    /home/A/rootA1.txt
    /home/A/rootA2.txt
    /home/A/oldA.xx
    /home/A/foo/fA1.txt
    /home/A/foo/fA2.txt
    /home/A/foo/oldfooA.xx
    /home/A/bar/barA1.txt
    /home/A/bar/barA2.txt
    /home/A/bar/oldbarA.xx

    From structure B:
    /home/B/
    newB.xx
    /home/B/foo/newfooB.xx
    /home/B/bar/newbarB.xx


    Result:
    /home/B/rootA1.txt
    /home/B/rootA2.txt
    /home/B/newB.xx <- not changed in B, even if the file names would be the same.
    /home/B/foo/fA1.txt
    /home/B/foo/fA2.txt
    /home/B/foo/newfooB.txt <- not changed in B
    /home/B/bar/barA1.txt
    /home/B/bar/barA2.txt
    /home/B/bar/newbarB.txt <- not changed in B
    I have tried with rsync but this will remove the destination folders when using rsync -zvr --existing

  2. #2
    Join Date
    May 2006
    Beans
    1,787

    Re: Copying files to new destination with same realative path?

    Quote Originally Posted by viggen View Post
    I wonder, if a recursive copy is performed from place A, is it possible to place the copy in a new destination B that is similar in structure where the file was copied from?

    MUST CRITERIA 1: Note that only the files of specific type will be copied (here *.txt)
    MUST CRITERIA 2: Note that there is files and folders in both structure A and B that must not be copied or changed.


    From structure A:
    /home/A/rootA1.txt
    /home/A/rootA2.txt
    /home/A/oldA.xx
    /home/A/foo/fA1.txt
    /home/A/foo/fA2.txt
    /home/A/foo/oldfooA.xx
    /home/A/bar/barA1.txt
    /home/A/bar/barA2.txt
    /home/A/bar/oldbarA.xx

    From structure B:
    /home/B/
    newB.xx
    /home/B/foo/newfooB.xx
    /home/B/bar/newbarB.xx


    Result:
    /home/B/rootA1.txt
    /home/B/rootA2.txt
    /home/B/newB.xx <- not changed in B, even if the file names would be the same.
    /home/B/foo/fA1.txt
    /home/B/foo/fA2.txt
    /home/B/foo/newfooB.txt <- not changed in B
    /home/B/bar/barA1.txt
    /home/B/bar/barA2.txt
    /home/B/bar/newbarB.txt <- not changed in B
    I have tried with rsync but this will remove the destination folders when using rsync -zvr --existing
    Look at 'find', 'tar' and 'cpio'.

  3. #3
    Join Date
    Nov 2010
    Beans
    2

    Re: Copying files to new destination with same realative path?

    Thanks!

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •