Menu

Combining 2 directory trees = duplicate file

Anonymous
2010-06-20
2012-12-08
  • Anonymous

    Anonymous - 2010-06-20

    Hi folks,

    I'm trying to combine two trees into one.  The problem seems to be that I can't use FULL paths but partial paths because the extraction path will be different every time.  So the first folder that exists in both trees triggers the "duplicate filename" error.

    Example:

    Tree1:
    C:\TEST\FOLDER1\SUB1\test1.txt
    C:\TEST\FOLDER1\SUB1\test2.txt
    C:\TEST\FOLDER1\SUB2\test3.txt

    Tree2:
    C:\TEST\FOLDER2\SUB1\test2.txt

    What I would like is that test2.txt in Tree2 should overwrite the one in Tree1.  And when extracted the folders SUB1 and SUB2 should exist in the root of the output folder.

    This is the simple version of the command I've been trying to tinker with:

    7Za a -r TESTING .\FOLDER1\* .\FOLDER2\*
    

    (default dir when running the command is C:\TEST)

    Please tell me if this is just impossible to achieve with the current 7Zip functionality or is there some neat solutions that I have completely missed?

    Thank You.

     
  • Igor Pavlov

    Igor Pavlov - 2010-06-20

    7Za a TESTING FOLDER1\  FOLDER2\

     
  • Anonymous

    Anonymous - 2010-06-30

    Thanks, ipavlov, but the subs SUB1 and SUB2 needed to be in the root of the archive.  That command line will result in:

    Date      Time    Attr         Size   Compressed  Name
    ------------- --- -------- --------  ----------------
    2010-06-21 22:12:44 ….A           32               FOLDER1\SUB1\test1.txt
    2010-06-21 22:14:49 ….A           32               FOLDER1\SUB2\test3.txt
    2010-06-21 22:15:53 ….A           61               FOLDER2\SUB1\test2.txt
    2010-06-21 22:12:56 ….A           32               FOLDER1\SUB1\test1.txt
    2010-06-21 22:15:53 D….            0            0  FOLDER2\SUB1
    2010-06-21 23:04:19 D….            0            0  FOLDER2
    2010-06-21 22:15:03 D….            0            0  FOLDER1\SUB2
    2010-06-21 22:14:00 D….            0            0  FOLDER1\SUB1
    2010-06-21 22:24:40 D….            0            0  FOLDER1
    ------------- --- -------- --------  ----------------

     
  • Anonymous

    Anonymous - 2010-06-30

    oops. made a typo, and I don't see the edit button.. so here's the correct listing (the problem is still the same):

    ------------- --- -------- --------  ----------------
    2010-06-21 22:12:44 ….A           32               FOLDER1\SUB1\test1.txt
    2010-06-21 22:12:56 ….A           32               FOLDER1\SUB1\test2.txt
    2010-06-21 22:15:53 ….A           61               FOLDER2\SUB1\test2.txt
    2010-06-21 22:14:49 ….A           32               FOLDER1\SUB2\test3.txt
    2010-06-30 15:55:58 D….            0            0  FOLDER2\SUB1
    2010-06-30 15:56:57 D….            0            0  FOLDER2
    2010-06-30 15:55:40 D….            0            0  FOLDER1\SUB2
    2010-06-30 15:54:25 D….            0            0  FOLDER1\SUB1
    2010-06-21 22:24:40 D….            0            0  FOLDER1
    ------------- --- -------- --------  ----------------

    Also:  "What I would like is that test2.txt in Tree2 should overwrite the one in Tree1"

    I forgot to mention that the file: "FOLDER2\SUB1\test2.txt" is newer than the file: "FOLDER1\SUB1\test2.txt", so I want the older overwritten by the newer file.

     
  • Zmey

    Zmey - 2010-07-06

    > 7Za a TESTING FOLDER1\  FOLDER2\

    This is not a solution, but a workaround. Ok, you propose to compress entire directories - nice, but what if I need only a couple of files from them, and not the whole contents? Here is a typical example:

    C:\Films\Dramas\list.txt
    C:\Films\Comedies\list.txt
    C:\Films\Movies\list.txt
    C:\Films\Westerns\list.txt
    C:\Films\Thrillers\list.txt

    All directories contain, along with 'list.txt', several dozen video files I do not want to compress.

    The most logical solution would be to put them all into a list file, and feed the latter to the archiver. But alas, 7za fails to process such a list file, and this definitely is not a good feature.

     
  • Anonymous

    Anonymous - 2010-07-07

    zmey_:
    that is not a  workaround: as I specced I want partial paths, but not the FOLDER1 or FOLDER2 parts.

    This works, but looks pretty ugly.  I have hoped that there were easier ways of doing this:

    @echo off
    if exist testing.* del testing.*
    cd FOLDER1
    xcopy /y /e /l /d *.* ..\FOLDER2\*.* | find /v "File(s)" >..\list.1
    ..\7Za a ..\testing @..\list.1
    cd ..\FOLDER2
    xcopy /y /e /l /d *.* ..\FOLDER1\*.* | find /v "File(s)" >..\list.2
    ..\7Za a ..\testing @..\list.2
    cd ..
    

    cheers..

     
  • Anonymous

    Anonymous - 2010-07-07

    Where's the edit button?..  Let's try quote next:

    @echo off

    if exist testing.* del testing.*

    cd FOLDER1
    xcopy /y /e /l /d *.* ..\FOLDER2\*.* | find /v "File(s)" >..\list.1
    ..\7Za a ..\testing @..\list.1

    cd ..\FOLDER2
    xcopy /y /e /l /d *.* ..\FOLDER1\*.* | find /v "File(s)" >..\list.2
    ..\7Za a ..\testing @..\list.2

    cd ..

     

Log in to post a comment.