Automate Script to run on Mac

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • weez999
    Visitor
    • May 2018
    • 3

    Automate Script to run on Mac

    I am not someone who knows how to write a script so I was hoping someone could kindly write one for me. If so, thank you in advance. I would like a simple script to do the following:

    (Environment: 2009 MacPro - Mac OS 10.11.6 El Capitan 128GB RAM - 4TB RAID of data)

    1. I have a folder within my data drive called DATA
    2. I want to have BeyondCompare automatically launch and run
    3. I have a session called Backup2 and it does a job to mirror my data files from 'DATA' to my Ext Hard Drive
    4. This session is part of my DataFileBackup session I've created

    Can someone kindly provide me a script or automator job to open beyond compare on its own and run the job to mirror my data for backups on a schedule of once every 6 hours?

    If you have any questions, let me know. Thanks again for anyone who is willing to help out.
  • Aaron
    Team Scooter
    • Oct 2007
    • 16002

    #2
    Hello,

    BC4's scripting works with the command line, so you could call to:
    bcompare "@/pathto/bcscript.txt"

    Where the script examples would be something like:
    log verbose "/Users/usernmae/bc4log.txt"
    load "Backup2 FC"
    sync mirror:left->right

    However, this makes a few assumptions. Is "Backup2" a Folder Compare session or a Folder Sync session? Scripting does not support a Sync session and will throw an error, but you can use the graphical interface to take a Sync session and open it as a Compare session, and re-save it. To do this, load the Folder Sync session in the interface, then in the Session menu -> Compare Base Folders to open a new tab of those folders in the Folder Compare session, then re-save the session as "Backup2 FC".

    Since this is working with a Sync Mirror, which can delete files in the destination, I would suggest testing with test folders first while learning the syntax of scripting. **There is no Preview during script, and there is no Undo after a sync.** You can also test this directly from the terminal before setting up as an automated task (using something like Automator).
    Aaron P Scooter Software

    Comment

    • weez999
      Visitor
      • May 2018
      • 3

      #3
      Originally posted by Aaron
      Hello,

      BC4's scripting works with the command line, so you could call to:
      bcompare "@/pathto/bcscript.txt"

      Where the script examples would be something like:
      log verbose "/Users/usernmae/bc4log.txt"
      load "Backup2 FC"
      sync mirror:left->right

      However, this makes a few assumptions. Is "Backup2" a Folder Compare session or a Folder Sync session? Scripting does not support a Sync session and will throw an error, but you can use the graphical interface to take a Sync session and open it as a Compare session, and re-save it. To do this, load the Folder Sync session in the interface, then in the Session menu -> Compare Base Folders to open a new tab of those folders in the Folder Compare session, then re-save the session as "Backup2 FC".

      Since this is working with a Sync Mirror, which can delete files in the destination, I would suggest testing with test folders first while learning the syntax of scripting. **There is no Preview during script, and there is no Undo after a sync.** You can also test this directly from the terminal before setting up as an automated task (using something like Automator).
      Aaron, so with that said, where do I put this script text? In windows you would create a batch file to run in like task scheduler but where do I do that in Mac? Do I make some sort of automator routine?

      Comment

      • Aaron
        Team Scooter
        • Oct 2007
        • 16002

        #4
        There are a few ways to automate on MacOS. The manual method is to launch a Terminal, then test using:
        bcompare

        This should launch BC4.
        If so, you can also launch in script mode with:
        bcompare "@/Users/username/bcscript.txt"

        Assuming this works, you can then make a bash script, AppleScript, or Automator routine to call this same command line. For example, you could define an AppleScript with
        tell application "Terminal"
        do script ("bcompare @/Users/username/bcscript.txt")
        end tell
        Aaron P Scooter Software

        Comment

        • weez999
          Visitor
          • May 2018
          • 3

          #5
          Thanks. The session I have is a folder sync where I mirror from left to right. (Left being the live folder and right being the backup. I want to do something like this. I dont care what's on the backup drive. I want the data from the directory on the computer directory (DATA) to be dropped onto the backup drive. My concern with file compare is if if runs and deletes data on the computer. I want the data copying to be one way with no chance of mistake is all.

          So, can that be done in some fashion?

          Comment

          • Aaron
            Team Scooter
            • Oct 2007
            • 16002

            #6
            Hello,

            Yes, although if you are still working out the logic of the sync, please use the interface first. The Folder Sync session itself cannot be referenced in scripting, however. You'll need to load the Folder Sync, then use the Session menu -> Compare Base Folders, and save a Folder Compare session version of your comparison. From this session, you can use the Actions menu -> Synchronize, and pick an Update or Mirror in a direction. One way won't delete files on the Source, but a Mirror would delete files in the Destination side.

            After this is working as expected, you can then call scripting manually from the Terminal. Launch using bcompare "@bcscript.txt"

            Automation is the last step you want to configure, since it would give no feedback and run automatically, you want to be sure it is working as you expect.
            Aaron P Scooter Software

            Comment

            Working...