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?
Script multiple compares
Collapse
X
-
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:\folder4Chris K Scooter Software -
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 advanceComment
-
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.Comment
-
Guest
-
Guest
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.Comment
-
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.txtChris K Scooter SoftwareComment
-
Script Multiple Profiles but Wait for User Action
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
What I have: Multiple folder pairs, that may or not be syncing at the end of the day
What I need:- Load profile and compare folders
- No differences found? Great: open next profile/folder pair
- Differences found? Wait for user action.
- User chooses action
- Open next profile/folder pair
Is this somehow viable?Comment
-
Sorry, not without external scripting to control which sessions are opened. If user interaction is needed, I would recommend opening every Sync in new tabs. This would open Sync even with nothing to do, but this would allow the user to visually confirm and dismiss those messages, moving on to the next tab and then committing syncs as they need to.
Do you need to control which profiles are loaded on the fly, or can these be saved as sessions ahead of time? You can call a set of Sync session names from the command line in a .bat file:
bcompare.exe "session1"
bcompare.exe "session2"
bcompare.exe "session3"
Or a single workspace that loads all of them:
bcompare.exe "workspaceName"
If you need to pass in a folder pair, this will be trickier since the command line does not force the Folder Sync session type, but the Folder Compare Session type, which does not have a saved/preferred method of syncing.Aaron P Scooter SoftwareComment
Comment