Script for syncing 2 folders ignoring both sides orphans

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • javalotodo
    New User
    • Nov 2009
    • 1

    Script for syncing 2 folders ignoring both sides orphans

    Hello,

    I'd like to automate the syncing of 2 folders (mirror local folder to remote folder -ftp-) but ignoring orphans at both sides, it means, updating only the files present in both sides.

    I'd like also to pass the log file path as a parameter.

    This is my script right now:

    # Turn logging on.
    log normal "D:\USUARIOS\Oscar\EMPRESA\ENCHUFIX\SISTEMAS\Desar rollo\Gestion\programas\bc-log.txt"
    # Load the default session and exclude all but certain file types.
    load <default>
    filter "unix-*.jpg;-*"
    # Confirm Yes to all
    option confirm:yes-to-all
    # Set the comparison criteria.
    criteria timestamp:10sec size
    # Load the base folders.
    load %1 %2
    # Copy different files left to right, delete orphans on right.
    sync mirror:left->right

    Thanks in advance,

    ------
    Oscar
  • Aaron
    Team Scooter
    • Oct 2007
    • 16007

    #2
    Hello,

    To ignore Orphans, you will have to use a custom Copy command instead of Sync Update or Mirror (which are predefined).

    A mirror also, by design, deletes orphans in the destination, so it doesn't sound like this is the logic you want to use.

    Instead, after the load, expand and select, then copy:
    load "%1" "%2"
    expand all
    select left.newer.files left.older.files left.diff.files
    copy left->right

    Please note, there is no Undo command. I would recommend testing with test folders first to prevent accidentally overwritting something unintended. left.newer files are Newer timestamp files on the left. Older have older timestamps (overwriting a newer file in the destination), and "diff" are files that have different sizes/criteria, but equal timestamps (which is an odd scenario, normally should be reviewed instead of synced).
    Aaron P Scooter Software

    Comment

    Working...