Jack G
Jack G

Reputation: 96

pass file format to beyond compare via command line

I've managed to activated beyond compare using command line:

"C:\Program Files\Beyond Compare 4\BComp.exe"  /qc /iu /K  "file1.c" "file2.c" & echo %errorlevel & exit

this allows me to get the result of comparison in cmd ERRORLEVEL variable.

I wan't to be able to set the file format used for this comparison. Manually, I can set it via the GUI through "format" button on the ribbon.

anyone know how this can be done? I've looked in the beyond compare scripting reference but to no avail.

thank you! Jack

Upvotes: 2

Views: 755

Answers (2)

Ashutosh Jindal
Ashutosh Jindal

Reputation: 18869

This is a slightly different use case. I often find myself comparing some JSON that I've copied to something else. Both the snippets exist in a clipboard manager that stores the clipboard history.

If you are using ZSH then you can use process substitution to do this as follows (note the =()):

bcomp -fv="Text Compare" =(pbpaste) =(pbpasteother)

The above generates temporary files which store the output of the commands (pbpaste , pbpasteother etc) and then sends them to Beyond Compare which is none the wiser. The only notable this is that you use bcomp which is the name of the command line tool that Beyond Compare installs which waits for a return code

However, the above doesn't allow me to compare the snippets as JSON.

However, with ZSH, one can also set the extension:

(TMPSUFFIX=.json; bcomp -fv="Text Compare" =(pbpaste) =(pbpasteother) )

We want to do the above in subshell to avoid impacting the current shell's env.

And that works!

Upvotes: 0

Chris Kennedy
Chris Kennedy

Reputation: 2899

Beyond Compare doesn't support forcing a file format with a command-line switch.

If the file extension is .c, Beyond Compare will use the built-in C/C++ file format. To use a different file format, open Tools > File Formats. The highest file format in the list with a matching file mask is used. To force a file format to be used regardless of mask, move it to the top of the list and set the file mask to *.*.

See the Command Line Reference topic in Beyond Compare's help file for supported command line parameters.

Upvotes: 2

Related Questions