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
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.
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!
Related
I'm using a Windows batch script in Powershell to convert all numbered .svg files in a folder to .png, using Inkscape on the commandline, based on the answer to a previous question here.
#echo off
for %%i in ("%~dp0*.svg") do (
echo %%i to %%~ni.png
"C:\Program Files\Inkscape\bin\inkscape.com" --export-type="png" --export-background-opacity=1.0 "%%i"
)
The script calls Inkscape again for each file, which I suspect is the main speed bottleneck (I have many files to convert). I would prefer to call Inkscape once and provide the list of files to convert.
Is it possible to use --shell mode to do this? I cannot find an example that uses this approach.
One approach I found was to use the interactive --shell mode with a sequence of "actions" and "verbs" such as this:
inkscape --shell
> file-open:file001.svg;export-filename:file001.png;export-do; file-open:file002.svg;export-filename:file002.png;export-do;
You can generate a long list of these action and verb sequences, one for each file. It works very well, but unfortunately I wasn't able to paste a large enough text string for the thousands of SVG files I wanted to convert. I think Powershell is limited by the amount of text you can paste into it, as is the usual command prompt.
Therefore it would be great if a future version of Inkscape accepted batch file containing such a list of commands. Currently it doesn't seem possible, as far as I can tell from the documentation.
Following on from your own answer, I created a 10,000 line file called inkscape.cmd that looks like this:
inkscape-version
inkscape-version
inkscape-version
...
...
and ran it with:
inkscape --shell < inkscape.cmd
I have only tested this on macOS as I don't have Windows.
No matter what my code is, even if my batch file is syntactically incorrect, even if it is absolutely correct and even if there is nothing to display on the screen the batch file when executed just displays the code as it is.
I read a similar question MSDOS prints the whole batch file on screen instead of executing but since that was on MS-DOS I hoped my issue could have a solution different than that.
Eg,
#echo off
set abcd=4
Even its batch file would just display the same lines as it is.
Please help.
Try "resetting" cmd if possible. U can try copying someone else's "cmd.exe" and replace it with yours using another bootable OS as windows wont allow that.
Here use my cmd.exe. https://drive.google.com/open?id=0B6ghonMKBfUSLVpRV0U5bG5pQTQ
Just in case u need to know I am using Windows 10 64 bit.
Check the file with an editor that allows you to see the encoding.
For example Notepad++ , you will see is very different the end of line via CF (\r) and LF (\n)
Your CMD can be recognizing EOL via \n only.
To determine whether your issue is really with line breaks being converted by your text editor (as the post you mention suggests), perform the following test:
Open a Command Line Window
Type the following command: copy con test.bat
The cursor will reposition itself under the command prompt, this is normal
Type the following 3 commands, each followed by the [Enter] key:
.
Echo Off
Set abcd=4
Echo abcd
Press CTRL-Z simultaneously (it will show up on screen as ^Z)
A confimation message should state: 1 file(s) copied.
Now type Test to run the batch file. If it runs properly, it means you are indeed dealing with line termination issues. Use a different text editor (don't use Notepad!!!), ideally one where you have an option to display the line termination characters (I personnally use NotePad++, it works great for these kinds of things but there are many others out there).
Perhaps there is a problem with your environment variables. Check the following:
Press WIN + R and run "%SYSTEMROOT%\System32\SystemPropertiesAdvanced.exe"
Click on "Environment Variables"
The system variables are listed at the bottom. Select the variable "Path" and click "Edit..."
Check whether the list contains "C:\Windows\System32" or "%SYSTEMROOT%\System32". If not, add one of those. You may have to restart your computer afterwards.
Where are the commands located for Command Prompt? I know this is possible in Linux, but what about windows?
I want to rename certain commands so I can make my own using the original name.
Im doing this on a 32bit Windows XP if that helps.
More specifically, where can I find the tree command?
https://superuser.com/questions/312926/windows-equivalent-of-which-command-in-linux
in windows 7 there's the where command.
You can overwrite the standard commands, but this will break a lot of stuff.
You would also have to modify your path environment variable
in windows 7 tree is located in C:\Windows\System32\tree.com
This might be a useful site for you
http://ss64.com/nt/
Use a bat file of the same name to override an inbuilt external command. Some commands are internal so you have to specify .bat. Also if calling the overridden program specify the extension.
There are two types of commands in Windows command prompt. The internal commands are built-in inside the command processor program, that is called cmd.exe. You may inspect such commands if you open cmd.exe file with an Hex editor, or even directly with Notepad (although doing that requires a lot of patience!); to know the location of cmd.exe file, type: set comspec. Examples of internal commands are DIR, COPY, TYPE, MD, etc. (the simplest ones) and all Batch-file commands, like GOTO, IF, FOR, REM, etc. There is no way to change the name of an internal command, unless you modify the cmd.exe file (for example, using the same Hex editor) that, although possible, is NEVER recommended!!!
The external commands reside in disk files with .com or .exe extension that are grouped in certain subdirectories, usually in C:\Windows\System or C:\Windows\System32; these subdirectories must appear in %PATH% variable in order to execute the external commands directly in the command prompt. You may locate the folder where an executable file resides using the following command, that review folders included in PATH variable only (you can not use wild-cards in this case):
for %a in (tree.com tree.exe) do #echo/%~$PATH:a
You may directly change the name of any command-name.exe file; however, this practice is not recommended. A simpler option is create a Batch file with the same name of a standard command (and .bat extension) and place it in a folder that will be included in PATH variable before the standard commands folder (or in the current directory). For example, create a file named tree.bat and place it in C:\Users\MyName\MyCommands; then, modify PATH variable this way: path=C:\Users\MyName\MyCommands;C:\Windows;C:\Windows\System32. If you need to use the standard tree command inside your tree.bat file, just include the proper extension: tree.com.
I would like to open a PDF in Photoshop from the command line. My current issue right now is that the default application for opening PDFs is Adobe Acrobat. I'm wondering if there is any parameter I can pass to specify which program to use when opening a file.
In other words, I want to emulate the option of "Open-with" when you right-click a file to open it with the non-default application, but from the command line.
I do not want to change the default application for PDFs to be Photoshop.
Any ideas?
All you need to is provide the filename as a command line argument:
photoshop <path to file>
(<path to file> needs to be quoted if it contains spaces)
For example:
photoshop "C:\Users\csterling\Documents\some document.pdf"
If the directory containing photoshop.exe isn't in your Path environment variable, you'll need to provide the full path:
"C:\Program Files\Adobe\Photoshop\photoshop" "C:\Users\csterling\Documents\some document.pdf"
This isn't a feature of the command prompt, it's a feature of the executable, i.e. photoshop.exe has to be programmed to accept a file to open as a command line argument. Fortunately, it is, as are the majority of Windows applications that operate on files.
In case you want this to work with relative path in PowerShell, here is the script:
function photo
{
$the_filename=resolve-path $args[0]
photoshop $the_filename
}
Then you can just type:
cd C:\Users\csterling\Documents
photo mypic.jpg
You can do it by using the start command:
start <program-name> <file-path>
In your case, you would have to do something like this:
start photoshop D:\open.pdf
Unfortunately, the current version of Photoshop doesn't support this operation out of the box. You can open the program: start "path_to_photoshop.exe", but there is no way to pass it a file to open. If you really want to do it, you will need to get something like this: https://www.eulanda.eu/en/access-photoshop-api-via-powershell-script. Sorry, I wish I had a better answer, especially since I wanted to be able to do this for a program I was working on.
How do I pipe standard error to a file in a DOS batch file? Piping using >> only pipes the standard output and the standard error still goes to the console.
Details of my issue:
I am running WinRAR via command line, in an automated daily backup. And the following example pipes WinRar's output, but not the error output which is what I want most, to winraroutput.txt:
RAR.exe a -esh -r "E:\backup.rar" "D:\*.*" >> winraroutput.txt
The issue is sometimes files are in use and when they are I want to know they were missed in the archive and record this in a .txt file next to each .rar file in case we ever have to go back. The missing files are easily replaced by reinstalling programs so it's no big deal to replace them, as long as we know they are missing. So it's just information that would be great to know, not necessary, in the time of need.
How do I output just the standard error output to the .txt file and, if possible but not necessary, leave the the regular output to the console?
Bonus points:
Bonus points if you can tell me how to delete the file if it's blank (no errors)! Asked here: How do I Detect (and Delete) a File if it is Empty using a Windows Batch File?.
Try this:
command.exe 2>file.txt
Or if you prefer not to see any errors, send it to nul:
command.exe 2>nul
This should leave std::cout on the console.