Announcement

Collapse
No announcement yet.

Command Line equivalent of Select Left File For Compare?

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

  • Command Line equivalent of Select Left File For Compare?

    I'll ask the question, then explain. BC3 Pro on Win7 Ent.

    Is there a Command Line equivalent to perform Select Left File For Compare when one right clicks on a file?

    I use TextPad as my text editor, and it has it's own, extremely primitive, compare tool. It's fine for very simple things, but by and large it isn't of any real use to me. Ideally, I'd like TextPad to be modified to integrate with an external compare tool, but that might be a long ways off.

    I want to script up a command to replicate Select Left File For Compare/Compare to "File1", and hopefully it's the same command line syntax.

    Sequence I'm imagining is:
    - Select File1
    - Run script (BCompare.exe File1 /"someoption")
    - Select File2
    - Run script (BCompare.exe File2 /"someoption")
    - BC3 opens comparing File1 and File2

    Please ask if you need me to clarify. It's clear inside my ADHD head, but that doesn't mean it's clear to others.

  • #2
    Hello,

    Unfortunately, we do not support this type of command line option in BC3. If TextPad exposes the Explorer menu, similar to how we do, you could select the file, go to Explorer, then use the Shell Extension. Another option would be to call BC3 twice, and two tabs would open, one for each file, then copy/paste the path of one tab into the comparison against the other.
    Aaron P Scooter Software

    Comment


    • #3
      OK, thanks. I went the scripted solution using AutoIt. From TextPad, I have a shortcut key to run the script, taking the file selected as input.

      Select File 1
      Run the script
      Select File 2
      Run the script
      BC3 opens up both files

      For BC3 users who favor a different text editor, the theory should hold.

      Code:
      ; ------------------------------------------------------------------------------
      ; Name     : BeyondCompareQueue.au3
      ; Version  : 1.0
      ; Type     : AutoIt 3.x
      ; Author   : Ken Grubb
      ; Email    : kgrubb@dol.wa.gov
      ; Written  : 02 Jul 2013
      ; Built    : Windows7 SP1 (AutoIt 3.3.8.1)
      ; Tested   : Windows7 SP1 (AutoIt 3.3.8.1)
      ; Keywords : file, compare
      ; Purpose  : Takes the command line input ($CmdLine[1]) of a file and compares it to the contents of the Clipboard
      ;            If the command line input and the contents of the Clipboard are the same, then a message is shown
      ;            If the contents of the Clipboard are a file, then the command line input and the contents of the Clipboard are compared using Beyond Compare
      ;            If the contents of the Clipboard are not a file, then the command line input is written to the Clipboard
      ; Usage    : autoit3.exe BeyondCompareQueue.au3 %1
      ; ------------------------------------------------------------------------------
      
      #include <File.au3>
      
      Opt("MustDeclareVars", 1)	;0 = no, 1 = require pre-declare
      
      Local $Quote = chr(34)
      Local $InputFile = $CmdLine[1]
      
      Local $ClipboardContents = ClipGet()
      If FileExists($ClipboardContents) Then
      	If $InputFile = $ClipboardContents Then
      		Local $szDrive, $szDir, $szFName, $szExt
      		Local $TestPath = _PathSplit($ClipboardContents, $szDrive, $szDir, $szFName, $szExt)
      		MsgBox(4096, @ScriptName, "Attempt to compare " & $szFName & $szExt & " to itself")
      	Else
      		Local $Command = $Quote & "C:\Program Files (x86)\Beyond Compare 3\BCompare.exe" & $Quote & " " & $Quote & $ClipboardContents & $Quote & " " & $Quote & $InputFile & $Quote
      		Run($Command)
      	EndIf
      Else
      	ClipPut($InputFile)
      EndIf

      Comment


      • #4
        Thanks for posting this solution!

        I'm sure other users will find it useful.
        Aaron P Scooter Software

        Comment


        • #5
          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