Page 1 of 2 12 LastLast
Results 1 to 10 of 12
  1. #1
    Join Date
    Mar 2007
    Posts
    3

    Default Script multiple compares

    Is it possible to write a script that will run multiple compares? If I have several different sessions I want to run to sync multiple locations, can I script a "wrapper" around all of the sessions and cause them to run at the same time?

  2. #2
    Join Date
    Oct 2007
    Location
    Madison, WI
    Posts
    4,728

    Default Re: Script multiple compares

    Yes, it is possible to have multiple actions in a single script.

    Example script:

    load c:\folder1 c:\folder2
    sync update:lt->rt
    load c:\folder3 c:\folder4
    sync update:lt->rt

    To run the script, use "BC2.exe @script.txt"

    You can also write a script that takes paths as variables.

    load %1 %2
    sync update:lt->rt

    Then use a batch file to call the script for each pair of folders.

    bc2.exe @script.txt c:\folder1 c:\folder2
    bc2.exe @script.txt c:\folder3 c:\folder4
    Chris K Scooter Software

  3. #3
    Join Date
    Mar 2007
    Posts
    3

    Default Re: Script multiple compares

    Thanks! That is exactly what I was looking for!

  4. #4
    Join Date
    Jul 2005
    Posts
    7

    Default Re: Script multiple compares

    I have also done this by reading the list of compares from a source text file by using a batch script.

    The only thing that seems to be happening incorrectly is that after the last compare runs, an additional BC session starts with no selection criteria for one side.

    Eventually, it will error out, with BC noting that it cannot load the selection.

    The calling script is:

    for /f %%a in ('sourcefile') do call :getcomp %%a

    :getcomp
    bc2 @bc-scriptfile %1 /silent
    GOTO :EOF


    The sourcefile is a text file containing a list of directories that have had snapshots taken with a common naming convention ("directory-name".bcss), one per line:

    dir1
    dir2
    dir3
    dir4


    The bc-scriptfile contains:

    log normal "\\server\share\%1_%date%_comp.log"
    criteria crc
    load "%1.bcss" "%1"
    expand all
    select rt.diff.files rt.orphan.files lt.orphan.files
    folder-report layout:summary options:display-mismatches,column-crc & output-options:html-color & output-to:c:\reports\%1_%date%.htm


    This produces reports named "dir1_yyyy-mm-dd.htm" but the last one shows up as "_yyyy-mm-dd.htm".

    Is this something I have done incorrectly in the Beyond Compare Script, or have I missed something in my batch script?

    Thanks in advance

  5. #5
    Join Date
    Oct 2007
    Location
    Bremen, Germany
    Posts
    583

    Default Re: Script multiple compares

    Hi Dee!

    In the batch-file simply add a GOTO :EOF between FOR and :getcomp

    Code:
    for /f %%a in ('sourcefile') do call :getcomp %%a
    GOTO :EOF
    
    :getcomp
    bc2 @bc-scriptfile %1 /silent
    GOTO :EOF
    Bye
    Christoph

  6. #6
    Join Date
    Jul 2005
    Posts
    7

    Default Re: Script multiple compares

    Thank you chrroe! That was exactly what I needed. I never would have thought of putting that there, but looking at it I see why it works now.

    The script now stops cleanly after the last entry in the sourcefile.

    Originally, my FOR statement was:

    FOR /F %%A in ('dir \\server\share /b') DO CALL :getcomp %%A

    but I had removed it thinking it was the source of the 'ghost' selection problem. I think I should be able to go back to it and ditch the sourcefile with the fix you provided.

  7. #7
    Guest

    Default Re: Script multiple compares

    How do you make the load use a saved session?

  8. #8
    Join Date
    Oct 2007
    Location
    Madison, WI
    Posts
    4,728

    Default Re: Script multiple compares

    Instead of passing two paths to the load command, pass the saved session name.

    Load "saved session name"
    Chris K Scooter Software

  9. #9
    Guest

    Default Re: Script multiple compares

    I also want to compare different pairs of folder, so using
    bc2.exe @script.txt c:\folder1 c:\folder2
    bc2.exe @script.txt c:\folder3 c:\folder4
    sounds nice.
    But I also need a way to get a result over all of this comparings, unfortunately I can't find any command in the srcipting reference for that. Having Result files is nice but does not allow a batch.
    My idea is that BC should set the ERRORLEVEL in DOS - or anything else what allows to transfer a status information outside of BC.
    Thank you very much.

  10. #10
    Join Date
    Oct 2007
    Location
    Madison, WI
    Posts
    4,728

    Default Re: Script multiple compares

    BC won't set the error level in the current version, but this is on our list for a future release.

    You can have BC append to a log file when it runs the script, then look at the log file after you've called the script for all of the folder pairs.

    To append to a log file, use the following command at the start of your script:

    log verbose append:c:\logfile.txt
    Chris K Scooter Software

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •