Hello,
On Linux it is quite easy to create shortcuts and add them to Open With
menu, for example I can open any image with the exiftool
command I configured.
I tried to create similar shortcuts on Windows via a .bat
file and via a shortcut but I can’t seem to figure it out hot to keep the terminal (CMD) open. I am not sure if the command works either.
I am wondering if any users here have figured that out and could share their experience here.
You can insert a “pause” command at the end of the script. Then it won’t exit until the user presses a key.
I tried it but it didn’t work.
Here is the content of my .bat file:
C:\Windows\exiftool.exe -a -s -G1
pause
I think it is but I might be wrong.
Maybe you can find a solution on StackOverflow
You don’t provide an input file for exiftool, so that won’t work.
C:\Windows\exiftool.exe
You should never install programs into C:\Windows.
That is the only way I know to launch exiftool, ffmpeg, etc. without typing the whole path.
Do you know windows analog for linux’s %f , %F, %u and %U by chance?
- %1 is what you use to specify the first command line argument
- I do this for all the command line programs I use: make a directory somewhere, preferrably under your c:\users\Andrius directory, put all the command line programs (and their .dlls, if needed) and put that directory in your PATH environment variable, accessed through the Control Panel → System → Advanced thing…
- ‘pause’ by itself should work as you intend.
- Consider installing MSYS2 and doing it all in bash…
As with Linux, you may add your directories to the Windows path. That way, you are able to install your files anywhere and have a more organized system. Steps:
1 Search env.
2 Go to Environment Variables…
3 Edit path under user variables.
4 Done! Now, commands can be typed without the full path and extension; e.g., gmic
instead of long-path-to\gmic.exe
.
PowerShell has more scripting capabilities than CMD. For reference on CMD or PowerShell, I often go to https://ss64.com/.
@snibgo’s IM site https://im.snibgo.com/ has lots of CMD scripts on image processing. Be warned: they tend to be too much for my poor heart. I think bash is so much easier.
From the OP, @Andrius wants to add a script to the Windows “open with” menu. As far as I know, that script must be a BAT script. It can’t be a bash script. (Corrections welcome, as always.)
So advice to use bash instead of BAT doesn’t help.
Of course, the “open with” BAT script could be a single-liner that actually calls a bash script to do whatever work is needed.
I agree that programs should not generally be installed in C:\Windows. However, exiftool.exe is a single-file program, without any DLLs or other dependencies, so putting it in a drectory that already exists isn’t a big problem. Personally, I use a single specific directory for all the single-file programs on my computer.
You can route the output of the command to a text file, example:
C:\Windows\exiftool.exe -a -s -G1 > output.txt
Not sure where the output.txt is saved; in c:\windows or the file’s path. When I remember correctly you can specify a path variable to the output file (I switched to Linux some time ago, not sure about that)
Thank you for the tip, I will look at this option. An output in terminal seems to be a better option for me though. I will try to use exiftool %1 pause
and see if it works.
Thank you Glenn. I will try ## 1-3 shortly here.
I will investigate on MSYS2 as well. I had WSL in my previous installation. It requires switching your Windows into developer mode and it is more like a virtual environment rather than a bash tool so I am not sure I want it again.
Thank you, afre, your post helps a lot!
I have no experience with MSYS2. I do use Cygwin, which has bash and many other tools (sed, awk, bc, etc), which run on Windows just like Windows CMD and other programs run on Windows. I wouldn’t recommend it as a substitute for a proper Unix environment, but if you want to run bash and Unix tools on Windows, it works fine.
Years since I had dealings with this, but back then it was often start
which saved the day.
Wanted to confirm that the following .bat file:
C:\Users\Andrius\Programs\exiftool.exe -a -s -G1 %1
pause
worked! Now I can read all metadata simply opening images with that batch file