Announcement

Collapse
No announcement yet.

Script for fast efficient sync of three sub folders. Skip if

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Script for fast efficient sync of three sub folders. Skip if

    1. I would like to compare the contents of three particular folders on two FTP servers. These three directories are all in a command directory call it F. The three particular directories are A, B and C.
    2. I would like to filter by some set of file extensions *.txt;*.bat;*.cmd;
    3. I would like to sync them such that if binary comparison is the same, then I sync the oldest time-stamp.
    4. I would like the sync to be fast by skipping binary comparison if the timestamp and file-size match. (i.e. GUI feature skip if Quick Tests indicate files are the same)
    5. I would like orphans to be sync'ed
    6. I would like to be prompted when the binary comparison fails for a given file.
    Example script is as follows. This is lacking several of the requirements above.

    load <default>

    # Load the base folders.
    load "ftp://servername1/F/A" "servername2/F/A"
    filter "*.txt;*.bat;*.cmd;-*"

    compare binary

    option confirm-prompt
    sync update:all


  • #2
    Hello,

    Can you clarify Step 3? By default, if the binary comparison is the same, then the files will have Same status, and are not included in a sync.
    And step 6? Script is designed to be automated, and prompts are reserved for errors or warnings, such as replacing read only. And by "fail" to you mean "different"? If so, I suspect you'd be better served by a couple of Folder Sync sessions, which have a large preview pane and let you review what the sync will perform before it acts on your data.

    **Please note, BC4 does not support an UNDO command, so please test with test data first and look over any preview information for files about to be overwritten or deleted. Script has no preview, as it is automated.**

    If you still need a scripted solution, I'd still recommend stepping through these steps first in the graphical interface initially, as the sync commands mirror actions you can take in the interface, while the interface allows previewing the comparison to see if it matches your expectations. Once you have those steps, automating them will be easier.

    Your current script has a couple minor issues, such as "compare" requires a selection, so currently isn't activating on your files. Also, if the filter is before the load, it can improve speed as the load will use it, instead of loading everything and then filtering out some items.

    An update requires a timestamp to be included in the sync logic, otherwise files cannot be Newer or Older status, required for a Sync Update command.
    Orphan files are included either way, and would be synchronized. A session or script can be configured to include both timestamp and binary comparisons, and to treat the binary as overriding or not.
    Aaron P Scooter Software

    Comment


    • #3
      Aaron,

      Thanks for the prompt response.

      This will be to synchronize "recipes" for a fleet of manufacturing tools. I have three use cases:
      1. New recipe created on one tool needs to be propagated to the rest of the tools. This is a simple propagation of orphan files. I wish this to happen automatically with no user interaction required.
      2. Recipe exists on two tools but their time stamps do not match but the rest of the binary comparison passes. I wish to synchronize the older of the two recipe timestamps. I wish this to happen automatically with no user interaction required.
      3. Recipe exists on two tools and neither time stamp nor binary comparison passes. I wish for the user to be notified and select which version to keep / synchronize.

      I will launch everything from a batch file or powershell script. The batch script will edit the beyond compare script.txt to update the FTP server in an iterative loop to sync each tool to the next.

      Is there a way for the session file to be converted into a script? Right now, I'm afraid the scripting reference is not sufficient for me to write the above use cases into a tidy script.

      Most important is UseCase 3 above. Is this possible

      ~Blender

      Comment


      • #4
        Hello,

        1) Is fairly easy to handle, as Orphans detect as a difference, and syncing or copying that specific status is a command.
        2) This isn't doable as stated. Criteria is definable, but after a Binary scan, and selecting the Only Equal binary files, there is no way to Touch (edit the timestamp) in a direction of the older file. You could always Touch in a direction (to Right) so the timestamps are made equal, but not whichever was Newer or Older. Copying the Newer timestamp over the Older Timestamp of Binary Equal files could only be done manually in the interface.
        3) Automation and the graphical interface are two separate instances. Any scripting does not offer a Prompt option. Either the script has to handle the task, or finish, and you can then launch the graphical interface to deal with whatever state the comparison is currently in (after an Orphan copy).

        Lastly, no, there is no way to set a macro in the interface to configure a set of steps for a script. The graphical session can define a variety of things (targets, comparison criteria, filters) but not the Actions (what to Copy/Sync, Touch, etc). These commands still need to be in script as select commands and the actions.
        Aaron P Scooter Software

        Comment

        Working...
        X