Can I Run Compare Sessions That I Created In BC From A Script (Hence 1 Simple Click)?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • aclockworkorangutan
    New User
    • Aug 2016
    • 2

    Can I Run Compare Sessions That I Created In BC From A Script (Hence 1 Simple Click)?

    I have a somewhat complex (probably overly complex) system of computers and/or external disks (all accessible on my network). The "data flow" is in general as follows:

    1. My PC<-> My Laptop (Mirror Left and Right)
    2. My PC -> Portable External Hard Drive (Mirror Right)
    3. Portable External Hard Drive -> External RAID (Mirror Right)
    4. Portable External Hard Drive -> USB Stick

    To accomplish this somewhat convoluted process I have created 4 sessions in Beyond Compare and I have to open the GUI and run each one separately, wait till they finish, then close Beyond Compare.

    Is there any way I could like export the sessions, then write like a batch/script to run those automatically (silently with no user interaction required) with a single mouse click? If so, does anyone know how and/or have examples?

    Thank you!

    Clockie
  • Aaron
    Team Scooter
    • Oct 2007
    • 16000

    #2
    Hello,

    Yes, we support automation via BC Scripting, documented in the Help file (F1) -> Using Beyond Compare -> Scripting chapter. Script can load sessions then perform a mirror with about two lines of text. An example script.txt could be

    log verbose c:\bclogs\log.txt
    load "My PC<-> My Laptop"
    sync mirror:left->right
    load "My PC -> Portable External Hard Drive"
    sync mirror:left->right
    load "Portable External Hard Drive -> External RAID"
    sync mirror:left->right
    load "Portable External Hard Drive -> USB Stick"
    sync update?:left->right

    *note the last sync is update since you left off the mirror.

    Important: Script does not Preview actions before taking them, and does not offer Undo. This can result in deleted information, especially with Mirror commands. I strongly recommend loading test folders/sessions first while learning scripting. Backing up these locations before testing script on them is also suggested. Once we're confident things are loaded and working correctly, script would allow the automation using Windows Task Scheduler.
    Aaron P Scooter Software

    Comment

    • aclockworkorangutan
      New User
      • Aug 2016
      • 2

      #3
      Originally posted by Aaron
      Hello,

      Yes, we support automation via BC Scripting, documented in the Help file (F1) -> Using Beyond Compare -> Scripting chapter. Script can load sessions then perform a mirror with about two lines of text. An example script.txt could be

      log verbose c:\bclogs\log.txt
      load "My PC<-> My Laptop"
      sync mirror:left->right
      load "My PC -> Portable External Hard Drive"
      sync mirror:left->right
      load "Portable External Hard Drive -> External RAID"
      sync mirror:left->right
      load "Portable External Hard Drive -> USB Stick"
      sync update?:left->right

      *note the last sync is update since you left off the mirror.

      Important: Script does not Preview actions before taking them, and does not offer Undo. This can result in deleted information, especially with Mirror commands. I strongly recommend loading test folders/sessions first while learning scripting. Backing up these locations before testing script on them is also suggested. Once we're confident things are loaded and working correctly, script would allow the automation using Windows Task Scheduler.
      Thank you for the response, this seems like a great way, however I can foresee some people having issues with things like paths in their batch file/dos command. For example:

      1. Do you pushd to the BC install folder then use relative paths for sessions?
      2. Do you run in the same directory as the batch file and then only provide the session name without path?
      3. Which BC executable do you run?

      Thank you,

      Jan

      P.S. I REALLY think it would be nice to have an export feature similar to how you can export global program settings except you would right click the session, select "Export as..." and save to an executable, batch file, etc.

      I am in NO WAY criticizing BC by the way, it's at least in the top 5 of my ALL TIME favorite software list. ^_^

      Comment

      • Aaron
        Team Scooter
        • Oct 2007
        • 16000

        #4
        Hello,

        Scripting supports passing in text on the command line, for example:
        bcompare.exe @script.txt "c:\folder1" "c:\folder2"

        Script can then reference the parameters with %1 and %2, etc
        load "%1" "%2"

        * documented in the main Using Beyond Compare->Scripting chapter.

        We do need the full path, not relative. Script can use session names, if you have a saved session name:
        load "session name"

        Scripting would use bcompare.exe. Bcomp.com and BComp.exe are used for vcs and other automated solutions. The differences are documented in the Help file -> Command Line Reference section.
        Aaron P Scooter Software

        Comment

        • Aaron
          Team Scooter
          • Oct 2007
          • 16000

          #5
          Additionally, enhancing to export a script from the GUI is something on our wishlist, but is not something we support at this time.
          Aaron P Scooter Software

          Comment

          Working...