Results 1 to 8 of 8
  1. #1
    Join Date
    May 2013
    Location
    Montgomery, AL
    Posts
    3

    Question Batch file -> script -> workspace -> session -> html

    Hi, fairly new user here.

    My job as a typical software developer has me diffing several source files against their source control versions and submitting that output as part of the change documentation. So far I've discovered that a "workspace" is a set of multiple "sessions", and I've created a workspace containing all the various diff sessions that make up my software change.

    I'm trying to write a batch file to invoke BC3 using a script that loads the previously-saved workspace, runs the multiple diffs against the multiple sessions contained in that workspace, and writes each diff output to a given filename in a given directory (in html format). I understand the command-line parameter to indicate a script is the "@" character, and the name of the workspace can be given too. It's just regular text (source code) files I'm comparing, nothing binary.

    My batch file looks like this:
    Code:
    "C:\Program Files (x86)\Beyond Compare 3\BComp.com" @"co123.scr" co123
    ...where "co123.scr" is my script filename, and the second "co123" is the name of my workspace. This workspace contains three separate pairs of files being compared, stored in three sessions.

    My script looks like this:
    Code:
    text-report layout:side-by-side output-to:"diffreport.html" output-options:html-color file1 file2
    My problem is that I don't seem to have a way to make it feed in the pairs of filenames from the workspace "co123" such that each pair is compared and written to separate html output results files. I don't know what to give it for "file1" and "file2" in the script above. Also I'll need separate output html files; the single "differport.html" in my example above won't do.

    I'd like to do all this from a single batch file and, if it's possible, from a single invocation of BC3. Some of my change orders involve as many as 12-15 source file changes, so I'd not like to end up with 12-15 batch files per change order scattered all over my desktop. I understand there will be some initial set-up, but after that I'd like to have it as automated as it can get.

    (Oh, I'm using Vault, so there's a local copy of the original (Vault) version of each file already on my hard drive. The path to those files is stored with my sessions so it looks like any old two text files being compared.)

    I hope that's clear enough. Can you help?

  2. #2
    Join Date
    Oct 2007
    Location
    Madison, WI
    Posts
    11,380

    Default

    Hello,

    Workspaces store more than a collection of sessions, it stores window position and tab layout. A workspace can be loaded from the command line for the graphical interface, but is not intended for scripting.

    Instead, scripting is a series of sequential commands. This way, you can load a session, then generate the report based on that session, then load the next session and generate its report, etc. This would be similar to going to each tab and generating each report in the graphical interface using a workspace.

    If you load a folder compare session in script, issue an expand all, then select files of a specific type (different, newer, etc), you can then generate the file level report on that selection:
    Code:
    load "folderSession1"
    expand all
    select files.newer files.different files.older
    text-report layout:side-by-side output-to:"diffreport1.html" output-options:html-color
    
    load "folderSession2"
    (etc)
    If you were generating a .txt report instead of HTML, you could append all of the files together at the end using a batch script, in order to have a single report file. Otherwise, you'll have one html report for each folder compare session.

    Does this help with your current workflow? Please let us know if you have any questions.
    Aaron P Scooter Software

  3. #3
    Join Date
    May 2013
    Location
    Montgomery, AL
    Posts
    3

    Default

    Hi and thanks for the quick reply. I take it from your answer I've been looking at this the wrong way. Please tell me if I understand correctly.

    First, I'm not interested in conducting a folder comparison. There are several thousand files in my folder structure, but only a handful of them (say, 3 to 15 individual files) get updated for any given software change. I'd rather have a means to indicate just those files that were changed.

    It seems you're trying to say that to accomplish my task, one way to do it would be a batch file containing multiple calls to BC3, using one session for each call. I take it the same script can be used, but I'd like to use a unique filename for each output file. So my batch file would probably look something like:

    Code:
    bcompare.exe @"htmldiffreport.scr" session1 outputfile1.html
    bcompare.exe @"htmldiffreport.scr" session2 outputfile2.html
    bcompare.exe @"htmldiffreport.scr" session3 outputfile3.html
    ...where session1, 2, and 3 are the names of sessions I would have previously saved (containing one pair of files being compared, each), and "htmldiffreport.scr" is my script. The three "outputfile?.html" filenames would represent the html filename that htmldiffreport.scr is to create.

    What would such a script look like, whose only job is to load the given session, run a html diff report, and write it to the "outputfile?.html" filenames given?

    Thanks!
    Last edited by cguru; 22-May-2013 at 11:58 AM. Reason: add code blocks

  4. #4
    Join Date
    Oct 2007
    Location
    Madison, WI
    Posts
    11,380

    Default

    Hello,

    Thanks for the clarification. If you know the name of your file pair, you could pass them in on the command line instead. I had assumed the folder compare due to the use of workspaces and assumed multiple folders/files in multiple sessions.

    bcompare.exe "@htmldiffreport.scr" "c:\fileA" "c:\fileB" "outputfile1.html"
    bcompare.exe "@htmldiffreport.scr" "c:\fileC" "c:\fileD" "outputfile1.html"

    Where the script can then be:
    text-report layout:side-by-side output-to:"%3" output-options:html-color "%1" %2"

    How does this work for you?
    Aaron P Scooter Software

  5. #5
    Join Date
    May 2013
    Location
    Montgomery, AL
    Posts
    3

    Default

    Looks good except that my path for the local copy of the Vault file looks something like this:

    C:\Users\<my_id>\AppData\Local\Sourcegear\Vault_1\ Client\81757756-E510-49A7-9363-5D4BBEBEBFDD\<my_id>\_sgvault\1408276819\2321474.4 274134

    ...and I don't want to have to type all that stuff into a batch file. Also it seems some of those directories change from one diff to the next... I haven't nailed that part down but it seems to be saved with the session (I think).

    Obviously I'm using BC as my main file diff utility, and it's configured for Vault too (called from Visual Studio). Do you know whether it's BC or Vault creating this path and strange filename?

  6. #6
    Join Date
    Oct 2007
    Location
    Madison, WI
    Posts
    11,380

    Default

    That looks like a uniquely generated guid. Is this the intended method of accessing the files from source control, or is there a 'check out' method that could be used to generate a traditionally named folder structure? This looks like the 'behind the scenes' storage area, and if Vault changes any of these locations while managing them, this would break any scripting or saved sessions (since we save the literal value of the location and are not tracking a folder based on content).

    BC3's scripting can activate on either level:
    - Given the pair of file names, and generate a report of their content.
    - Given a pair of folders (or a saved folder session with a pair of folders), then select the items inside, and generate a text report of their content.

    We would just need to figure out the most consistent method of getting to your files, so that if Vault does change something it does not break all of this setup.
    Aaron P Scooter Software

  7. #7
    Join Date
    Nov 2014
    Posts
    4

    Default Loaded session for data Compare in the batch mode

    Quote Originally Posted by Aaron View Post
    Hello,

    Workspaces store more than a collection of sessions, it stores window position and tab layout. A workspace can be loaded from the command line for the graphical interface, but is not intended for scripting.

    Instead, scripting is a series of sequential commands. This way, you can load a session, then generate the report based on that session, then load the next session and generate its report, etc. This would be similar to going to each tab and generating each report in the graphical interface using a workspace.

    If you load a folder compare session in script, issue an expand all, then select files of a specific type (different, newer, etc), you can then generate the file level report on that selection:
    Code:
    load "folderSession1"
    expand all
    select files.newer files.different files.older
    text-report layout:side-by-side output-to:"diffreport1.html" output-options:html-color
    
    load "folderSession2"
    (etc)
    If you were generating a .txt report instead of HTML, you could append all of the files together at the end using a batch script, in order to have a single report file. Otherwise, you'll have one html report for each folder compare session.

    Does this help with your current workflow? Please let us know if you have any questions.
    Hello,
    I have tried above sugestation to load session for excel data compare and getting below error. Is there a way to load data compare session?

    11/18/2014 8:34:16 AM >> load "RMC"
    11/18/2014 8:34:16 AM Fatal Scripting Error: Loaded session must be Folder Compare session
    11/18/2014 8:34:16 AM Script completed in 0.00 seconds

    Thanks,

  8. #8
    Join Date
    Oct 2007
    Location
    Madison, WI
    Posts
    11,380

    Default

    The above suggestion is specific to loading the folder compare, which is the only supported session type.

    You can load the Folder Compare in the GUI, set the filter to show only Excel files, then double click a pair of aligned Excel files (same name on the left and right side). Then, in this child session setting, re-configure the Session Settings as you did before, but update the dropdown from "Use only for this view" to "Use for all files in parent session". Close the child session and re-save the folder compare. Now, loading the folder compare and using the above script with a data-report will used the saved child session settings.

    Or, you can update the Data Compare default session settings (if a global usage works for all files), then use the script:
    data-report layout:side-by-side output-to"c:\report.html" output-options:html-color "c:\file1.xls" "c:\file2.xls"
    as the data-report can directly accept file names and use the default session settings to generate a report.
    Aaron P Scooter Software

Tags for this Thread

Posting Permissions

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