PDA

View Full Version : Multiple folders query


captedgar
14-Jan-2010, 11:24 AM
Hi there

We have been using BC2 and BC3 for a while now and this has been a wonderful tool in our daily admin work.
We have about 100 servers and we do server compares everyday and this takes about 30 mins to do the job.
I have read up on BC help section before writing this question. So i shall explain this in detail

We use batch file to do our BC.

The first batch file is called SERVERCOMPARE.bat
The contents of this is as follows
del /Q "C:\BC\BusinessLogic\Reports\*.txt"
start C:\BC\BusinessLogic\Servers-Set1.bat
There are multiple batch files which duplicates the above batch file contents to cater for 100 servers but i have not included them here but contents are similar.

The second batch file is called Servers-Set1.bat
The contents of this is as follows

call C:\BC\BusinessLogic\FoldersCompare.bat server1 server2

There are extra batch files which duplicates the above batch file contents to cater for 100 servers but i have not included them here but contents are similar.

The third batch file is called FoldersCompare.bat.
The contents of this is as follows


del /Q "C:\BC\BusinessLogic\Reports\*%1*%2*.txt"

call C:\BC\BusinessLogic\BC.bat %1 "\c$\folder1\subfolder1" %2 "\c$\folder1\subfolder1"
ren C:\BC\BusinessLogic\Reports\BC-report.txt subfolder1-%1-%2.txt

call C:\BC\BusinessLogic\BC.bat %1 "\g$\folder1\subfolder2" %2 "\g$\folder1\subfolder2"
ren C:\BC\BusinessLogic\Reports\BC-report.txt subfolder2-%1-%2.txt

call C:\BC\BusinessLogic\BC.bat %1 "\h$\folder1\subfolder3" %2 "\h$\folders1\subfolder3"
ren C:\BC\BusinessLogic\Reports\BC-report.txt subfolder3-%1-%2.txt


The fourth batch file is called BC.bat.
The contents of this is as follows


echo off
del /Q "C:\BC\BusinessLogic\Reports\BC-report.txt"
echo off
"C:\Program Files\Beyond Compare 2\BC2.exe" @"C:\BC\BusinessLogic\BCScript.txt" "\\"%1%2 "\\"%3%4


Lastly, BCScript.txt has the following contents


log verbose append:C:\BC\BusinessLogic\Reports\verboselog-report.txt
filter "-\Cache\;-PCAPI.log;-Serialisers.Cfg;-DB*.*;-*.backup;-*testing*.dll;-\Stage\;-\v2.0.5.232\;-dripplier.exe;-\Pictures\"
criteria size
compare binary
load %1 %2
expand all
select all
folder-report layout:side-by-side options:column-size,column-timestamp,column-crc,display-mismatches &
output-to:C:\BC\BusinessLogic\Reports\BC-report.txt


This is my version. The backup version works fine like i said but takes 30 mins.
The above version of mine works fine and takes only 3 mins to do the compare

My main question is my version compares all the folders but doesn't report any mismatches on some of them. To explain this, in the FoldersCompare.bat, only the folders which are bolded in the below code reports mismatches but not all of them. I have tested this by creating orphans on some servers for those folders which do not provide mismatches. If i change the criteria in the BCScript.txt to binary or CRC, it reports mismatches all the folders mentioned below but takes longer then the backed version. The backed version also has the criteria set to size only but this reports mismatches on all the folders of their respective servers. The only difference between the backed up and my version is the BCscript.txt. You can find the contents of the BCscript.txt from the backed up version below after the FoldersCompare.bat

Please suggest/help

FoldersCompare.bat
The contents of this is as follows


del /Q "C:\BC\BusinessLogic\Reports\*%1*%2*.txt"

call C:\BC\BusinessLogic\BC.bat %1 "\c$\folder1\subfolder1" %2 "\c$\folder1\subfolder1"
ren C:\BC\BusinessLogic\Reports\BC-report.txt subfolder1-%1-%2.txt
call C:\BC\BusinessLogic\BC.bat %1 "\g$\folder1\subfolder2" %2 "\g$\folder1\subfolder2"
ren C:\BC\BusinessLogic\Reports\BC-report.txt subfolder2-%1-%2.txt

call C:\BC\BusinessLogic\BC.bat %1 "\h$\folder1\subfolder3" %2 "\h$\folders1\subfolder3"
ren C:\BC\BusinessLogic\Reports\BC-report.txt subfolder3-%1-%2.txt


BCScript.txt from the backedup version


load %1 %2
log verbose append:C:\BC\BusinessLogic\Reports\verboselog-report.txt
filter "-\Cache\;-PCAPI.log;-Serialisers.Cfg;-DB*.*;-*.backup;-*testing*.dll;-\Stage\;-\v2.0.5.232\;-dripplier.exe;-\Pictures\"
expand all
select all
criteria size
compare binary
folder-report layout:side-by-side options:column-size,column-timestamp,column-crc,display-mismatches &
output-to:C:\BC\BusinessLogic\Reports\BC-report.txt

Aaron
14-Jan-2010, 01:54 PM
Hello,

The difference is the select all and compare commands.

Compare works on the selection. In your version, you run the compare command on no selection, while in the backup version it expands all (to get all files in subfolders), does a select all to select all files, and then runs the comparison.

This can actually be changed. If you want the comparison to run on everything, simply make it the criteria before running the load command.

log verbose append:C:\BC\BusinessLogic\Reports\verboselog-report.txt
criteria binary
load %1 %2
expand all
folder-report layout:side-by-side options:column-size,column-timestamp,column-crc,display-mismatches &
output-to:C:\BC\BusinessLogic\Reports\BC-report.txt


How does that work for you?

captedgar
20-Jan-2010, 03:12 AM
Thanks Aaron

This has worked to my expectations.

Thanks again for resolving my query

captedgar
20-Jan-2010, 03:24 AM
Although Aaron, i have one query about our BC batch file which i still don't seem to get my head around for. It is the BC.bat file mentioned below

echo off
del /Q "C:\BC\BusinessLogic\Reports\BC-report.txt"
echo off
"C:\Program Files\Beyond Compare 2\BC2.exe" @"C:\BC\BusinessLogic\BCScript.txt" "\\"%1%2 "\\"%3%4

Why do we have to pass double parameters in the above batch file. see the highlighted text in the code

regards

Michael Bulgrien
20-Jan-2010, 07:54 AM
It would appear that your script is designed to be passed the server name followed by the file path as separate parameters.

For example: BC servername1 \path\filename servername2 \path\filename

Passing the servername separately from the path makes the script more flexible since you can leave the path alone and pass different server names to do the same compare on a different set of servers.

Aaron
20-Jan-2010, 02:50 PM
I am not sure why you would need %1%2 then %3%4. That would have to do with the commandline call to that bat file, and what is passed in on that line. If I had to guess, it probably has to do with spaces in your parameter name (which would make them separate parameters). You should have quotes around things with spaces, and often should try to avoid using spaces when you can when dealing with the command line.