Open with...

Plug-ins, add-ons, skins, icons, templates and other downloads. Contributions are welcome.

Moderators: XnTriq, xnview

User avatar
omniplex
Posts: 122
Joined: Thu Feb 10, 2011 1:52 pm
Location: Hamburg
Contact:

Open with...

Postby omniplex » Mon Jan 18, 2016 7:44 pm

XnView has an "open with" feature, i.e., if you right-click on a file you can select "open" F3 or "edit" F4 to get the same effect as in Windows explorer "open" or "edit". For images this is rather boring, "open" in explorer on my box starts XnView, so when I am already in XnView I rarely need F3. It is possible to define additional "open with" programs in XnView for any file, e.g., a hex. viewer better than the XnView built-in hex. viewer.

Disadvantages, when you want to get rid of a bad "open with" idea XnView only offers to delete everything, back to only F3 and F4. An additional "open with" tool works for any file, you cannot define something only for, say, PNG. Recently I decided that I want an "open command prompt here" feature also within XnView. And after that worked as expected I modified it to open tweakpng for PNG, or a command prompt for everything else. Eventually I arrived at a script opening exiftool -k for ICC / MIE / XMP, or dcraw -i -v for camera raw.

If you want similar "open with" functions you can copy and edit the code shown below, save it in a tools folder, where you have exiftool / dcraw / tweakpng / etc., and define it as "open with" application in XnView. For the latter XnView first offers to open an *.exe, but it is a simple plain text *.cmd, you have to select * to see all files including *.cmd, not only *.exe and also not only *.bat. The name doesn't matter, I use OPENDIR.cmd:

Code: Select all

@setlocal enableextensions & echo off
if not "%~2" == ""     call "%~0" "%*"
if not "%~2" == ""     goto :EOF
if     "%~1" == ""     goto HELP
if     "%~1" == "?"    goto HELP
if     "%~1" == "/?"   goto HELP
if     "%~1" == "-?"   goto HELP
set PADD=%~dp0;%PATH%;.
set NEED="%~1"
if not exist "%~f1"    goto NEED
set NEED="%~f1\."
if     exist "%~f1\*"  goto OKAY
set NEED="%~f1\.."
if /I "%~x1" == ".ICC" goto EXIF
if /I "%~x1" == ".ICM" goto EXIF
if /I "%~x1" == ".MIE" goto EXIF
if /I "%~x1" == ".PNG" goto PING
if /I "%~x1" == ".ARW" goto CRAW
if /I "%~x1" == ".CR2" goto CRAW
if /I "%~x1" == ".CRW" goto CRAW
if /I "%~x1" == ".DNG" goto CRAW
if /I "%~x1" == ".ERF" goto CRAW
if /I "%~x1" == ".KDC" goto CRAW
if /I "%~x1" == ".KRO" goto CRAW
if /I "%~x1" == ".MEF" goto CRAW
if /I "%~x1" == ".MRW" goto CRAW
if /I "%~x1" == ".NEF" goto CRAW
if /I "%~x1" == ".NRW" goto CRAW
if /I "%~x1" == ".ORF" goto CRAW
if /I "%~x1" == ".PEF" goto CRAW
if /I "%~x1" == ".RAF" goto CRAW
if /I "%~x1" == ".RAW" goto CRAW
if /I "%~x1" == ".RW2" goto CRAW
if /I "%~x1" == ".RWL" goto CRAW
if /I "%~x1" == ".SR2" goto CRAW
if /I "%~x1" == ".SRW" goto CRAW
goto OKAY
:EXIF --------------------------------------------------------------
set NEED=exiftool.exe
for %%x in (%NEED%) do if exist "%%~f$PADD:x" set NEED=%%~f$PADD:x
if     exist "%NEED%"  goto CALL
set NEED=exifgui.exe
for %%x in (%NEED%) do if exist "%%~f$PADD:x" set NEED=%%~f$PADD:x
if     exist "%NEED%"  goto OPEN
if not exist "%NEED%"  goto NEED
:PING --------------------------------------------------------------
set NEED=tweakpng.exe
for %%x in (%NEED%) do if exist "%%~f$PADD:x" set NEED=%%~f$PADD:x
if     exist "%NEED%"  goto OPEN
if not exist "%NEED%"  goto NEED
:CRAW --------------------------------------------------------------
set NEED=dcraw.exe
for %%x in (%NEED%) do if exist "%%~f$PADD:x" set NEED=%%~f$PADD:x
if not exist "%NEED%"  goto NEED
call "%NEED%" -i -v "%~f1"
goto WAIT
:OPEN --------------------------------------------------------------
start "%~n0" /D . "%NEED%" "%~f1"
goto :EOF
:CALL --------------------------------------------------------------
call "%NEED%" "%~f1"
goto WAIT
:NEED --------------------------------------------------------------
echo/
echo Error: %~nx0 found no %NEED%
:HELP --------------------------------------------------------------
echo Usage: %~nx0 FILE
echo/
echo Default action:  Open a command window (CMD.EXE) in the folder
echo of the specified existing FILE or subdirectory.
echo/
echo Edit this script to run another program depending on the FILE
echo extension, e.g., for a PNG start TWEAKPNG.EXE, or for MIE start
echo EXIFTOOL.EXE.
echo/
:WAIT --------------------------------------------------------------
set NEED="%CMDCMDLINE:)=%"
for /F "usebackq tokens=2" %%c in ('%NEED%') do if %%c == /c pause
goto :EOF
:OKAY --------------------------------------------------------------
endlocal & cd /D "%NEED%" & cmd /k title %~nx0

Return to “Customization”

Who is online

Users browsing this forum: No registered users and 2 guests