New to scripting - need a simple script

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • RaceTrak
    Visitor
    • Feb 2004
    • 7

    New to scripting - need a simple script

    Hello,

    Sorry if this is a really basic question but I can't quite wrap my head around "filter" and "select."

    What I want to do is load a saved session, move ZIP files from left to right, then sync all other files from left to right.

    I can do this by running 2 separate scripts, but I can't quite figure out how to do it in one script (i.e., I either end up moving everything or syncing everything...).

    I'm sure I'm missing something simple or doing something stupid - but I can't figure it out and thought this would be the quickest way... (I went looking for some sample scripts but none of them quite do what I need. Is there a library of samples somewhere online other than what is in the help files?)

    Thanks for any help!
  • Aaron
    Team Scooter
    • Oct 2007
    • 15997

    #2
    Hello,

    Script commands execute sequentially, so you can:
    load folders
    set a filter for zip
    move them
    set the filter for "not zips"
    perform a sync

    Would this be the logic you are looking for? Scripting Reference is found in the Help file -> Using Beyond Compare chapter -> Scripting section. The syntax would be something similar to:
    load "session name"
    filter "*.zip"
    expand all
    select left.files
    move left->right
    filter "-*.zip"
    sync update:left->right
    Aaron P Scooter Software

    Comment

    • RaceTrak
      Visitor
      • Feb 2004
      • 7

      #3
      Yes - thank you - I have looked at the scripting help, but I am mostly just confused with "filter" and "select" -- i.e., does "filter" filter OUT files or does it "select" the things that match the filter? And then what does "select" do? Does it pick the things that were "filtered in" to operate on or does it pick the things that were "filtered out"?

      Just inexperience / foggy memory for me... I actually used to do a little database/SQL programming back in the days of FoxPro (for DOS!). I was just a hack though -- I could get eventually get it to do what I wanted to do, but I was not formally trained/educated and was certainly not fluent... same with scripting - I can usually figure it out, but I just haven't had the time to sit and tinker.

      Thanks again!

      Originally posted by Aaron
      Hello,

      [snip]

      load "session name"
      filter "*.zip"
      expand all
      select left.files
      move left->right
      filter "-*.zip"
      sync update:left->right

      Comment

      • Aaron
        Team Scooter
        • Oct 2007
        • 15997

        #4
        Hello,

        Filter changes what can be in view (include or exclude, depending on the syntax used).
        The select command can then select files that exist in view.

        This mirrors actions you can take in the main interface. To preview, load the graphical interface, load a new Folder Compare, load your session, and copy/paste the filter string (without quotes) into the Filters toolbar box. This lets you preview which items remain visible.

        Selecting is then done with a combination of Display Filters and the mouse or the Edit menu -> Select commands. You can then alter the filter, and use the Sync command under the Actions menu -> Synchronize. If you are foggy about the steps, I would recommend stepping through each step in the graphical interface first (each script line roughly corresponds to an action in the interface), so you can see how each works with a graphical preview. The script will then be easier to work with, similarly stepping through (but not previewing) each action.
        Aaron P Scooter Software

        Comment

        • Aaron
          Team Scooter
          • Oct 2007
          • 15997

          #5
          I should add that Script actions and interface actions do not support Undo. So please test with test data/folders first while learning how to perform these actions or use the script. Script itself offers no preview or ability to undo after it is executed.
          Aaron P Scooter Software

          Comment

          Working...