Announcement

Collapse
No announcement yet.

Select left/right side to compare - from cmd line

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Select left/right side to compare - from cmd line

    Is there a way to use the command prompt to "Select left side to compare", then use the command prompt to "Select right side to compare" two files/folders?

  • #2
    Re: Select left/right side to compare - from cmd l

    There isn't a "select left side to compare" or "compare to ..." command on the command line.

    To launch a folder comparison from the command line, use "bc2.exe c:\folder1 c:\folder2".

    To launch a file comparison, use "bc2.exe c:\file1.txt c:\file2.txt".

    For further automation, you can also script Beyond Compare. For details, see the Scripting forum or the Command Line and Scripting section of the help file.
    Chris K Scooter Software

    Comment


    • #3
      I often have multiple VCS workspaces open version control clients, and I'd like to compare a file in one workspace with another file in a different workspace.

      The following batch file can be used to select the left file and then compare it against another file.

      I called my batch file "BC_SelectCompare.bat". When executed with the "/left" argument, the specified file or folder path is stored in a file beside the batch file. In my case, that file is called "BC_SelectCompare.left". When executed with the "/compare" argument, Beyond Compare is loaded to compare the previously stored left path against the new path.

      This works for both files and folders.

      Code:
      @ECHO OFF
      
      if "%~1"=="" GOTO:help
      
      if %1==/left GOTO:left
      
      if %1==/compare GOTO:compare
      
      :help
      ECHO Compares one file or folder to another using Beyond Compare.
      ECHO.
      ECHO BC_SELECTCOMPARE [/left ^| /compare] path
      ECHO.
      ECHO   /compare    Compares the specified path to the previously set left path.
      ECHO   /left       Stores the left file or folder path.
      ECHO   path        Specifies the file or folder to be compared.
      ECHO.
      ECHO.
      ECHO Usage:
      ECHO.
      ECHO    Set the left file or folder path:
      ECHO.
      ECHO       %~nx0 /left path
      ECHO.
      ECHO    Compare the specified path to the previously stored left path:
      ECHO.
      ECHO       %~nx0 /compare path
      ECHO.
      GOTO:eof
      
      :left
      ECHO %2>"%~dp0%~n0.left"
      GOTO:eof
      
      :compare
      SET /P Left=<"%~dp0%~n0.left"
      "C:\Program Files (x86)\Beyond Compare 4\BComp.exe" %Left% %2
      GOTO:eof

      Comment

      Working...
      X