[Webinar] Streamline your web hosting managementRegister Today

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 701
  • Last Modified:

Image Management: Mass Converter Adobe DNG to JPEG?

I've several thousand Adobe DNG high-res images that need to be simply converter/extracted to JPEG. My intention is to just select the root folder and the tool runs recursively through the n-level directory structure.
Ideally, this tool is free, since I will use it once.
Thanks guys.
  • 2
  • 2
1 Solution
I know not much about DNG but since its adobe, perhaps it can be open in Photoshop. From there you can apply recursive actions on a folder.

This might help if Photoshop will be able to open DNG files.


go4javaAuthor Commented:
I believe EXIFTOOL http://www.sno.phy.queensu.ca/~phil/exiftool/ can do the job, but it looks complicated to me.
Can it EXTRACT JPEG image from a Pentax/Adobe-DNG raw file?
Anybody out there with experience on this problem? Thanks.
go4javaAuthor Commented:
...there are 2 solutions:

REM *** exiftool ***
exiftool -copy1:previewimage -b test.dng > test.jpg

REM *** dcraw ***
dcraw.exe -e test.dng
Hi go4java

I know this is closed, but there is another batch conversion method using the free IrfanView image viewer/editor (http://www.irfanview.com).

Although IrfanView does not specifically list *.DNG as a supported import or export file format, it would seem that the DNG files I found and checked out (http://examples.oreilly.com/9780596510527/) are really just TIFF files, so that's how IrfanView treats them.

There are a lot of command line options available to IrfanView and these can be found in the "i_options.txt" file in the \Program Files\IrfanView folder once installed.  If installing IrfanView as a supplementary image editor to your main one, then make sure that you do not associate any file types with it (Options menu > Set File Associations).

The following batch file (eg. "Convert_DNGs.cmd") would convert all *.DNG files in whatever folder you place the batch file, and in all sub-directories thereof, to *.JPG files of the same names in the same folders as each of the *.DNG files reside.  It leaves the original *.DNG files.

@echo off
set CurrDir=%~dp0
set CurrDir=%CurrDir:~0,-1%
set CONVERT=C:\Progra~1\IrfanView\i_view32.exe

for /r "%CurrDir%" %%a in (*.DNG) do (
    echo Converting %%~nxa To %%~na.jpg ...
    %CONVERT% "%%~fa" /convert="%%~dpna.jpg"
    echo Done with Return Code of: %errorlevel%


The command to run IrfanView like this does not show the IrfanView user interface or output any messages to the screen other than error messages.  You could optionally redirect errors to a log file by changing the main command to this:

%CONVERT% "%%~fa" /convert="%%~dpna.jpg" 2>>%CurrDir%\ConvertLog.txt

IrfanView closes after each file conversion, and should issue an Exit Code of Zero on success.  Anything other than 0 constitutes an error, so that could be tested and logged if desired with something like the following line inserted after the command line in the batch file:

if not errorlevel 0 ECHO Failed to convert %%a>>"%CurrDir%\ErrorLog.txt"

The FOR /R command walks through the directory rooted at the given start path (in this case the folder containing the batch file) and executes the command in each directory it passes through.  If it finds no *.DNG files, that will not constitute an error - it just carries on walking.

You could optionally delete the original *.DNG file after conversion to *.JPG, but I personally would first check to ensure that the files WERE converted successfully before doing so.

A word of warning and a tip.  If you add an "echo" in front of the main command in the above batch file it will not execute the command but will display the command on the screen:

echo %CONVERT% "%%~fa" /convert="%%~dpna.jpg"

That can be redirected to a file like this:

echo Converting %%~nxa To %%~na.jpg ...">>"%CurrDir%\TestCommands.txt"

echo %CONVERT% "%%~fa" /convert="%%~dpna.jpg">>"%CurrDir%\TestCommands.txt"

echo Done!">>"%CurrDir%\TestCommands.txt"

The reason I mention this is just so that you can be sure that the modified variables do actually expand to the correct filenames and paths.

%%a   will contain the full path, filename, and extension of the file currently being processed.  The FOR statement is a loop, so the %%a variable will contain details of a different file with each pass, and the variable can be modified in many ways, such as the modifiers I used in the batch file above.

%%~na  will contain ONLY the file name - no path and without the extension.
%%~nxa   will contain the file name and extension without the path.
%%~fa  will contain ONLY the path to the file.
%%~dpna  will contain the Drive Letter, path to, and file name, BUT no extension.

You will notice that I used  %%~dpna  and then tacked the .JPG extension on at the end to provide the new extension.  I used the full paths to each of the files being found by the FOR loop for the IrfanView command.

If you really wanted to delete the original source *.DNG files from within the batch file, then perhaps a good method would be to compile a separate listing of all *.DNG files and *.JPG files after the processing finished, and then compare them afterwards.  The lists could be made to only contain paths and filenames so that a comparison wouldn't flag up the different extensions.

Example - to be placed below the closing ) of the FOR loop:


echo Finished Processing.
echo Creating reports ...
for /r %CurrDir% %%a in (*.dng) do @echo %%~dpna>>"%CurrDir%\DNG_List.txt"
for /r %CurrDir% %%a in (*.jpg) do @echo %%~dpna>>"%CurrDir%\JPG_List.txt"
FC /L /C "%CurrDir%\DNG_List.txt" "%CurrDir%\JPG_List.txt">>"%CurrDir%\DiffReport.txt"
echo Checking Differences Report ...
for /f "skip=1 tokens=2 delims=:" %%a in (%CurrDir%\DiffReport.txt) do @echo Results:%%a

del "%CurrDir%\DNG_List.txt" > nul
del "%CurrDir%\JPG_List.txt" > nul

instead of redirecting the success of the FC (File Compare) program to file, you could do an %errorlevel% check.  You would be looking for a Zero, ie. No Differences Found before you would delete any of the *.DNG files.

FC /L /C "%CurrDir%\DNG_List.txt" "%CurrDir%\JPG_List.txt" > nul
if not errorlevel 0 goto :ERRORS
for /r "%CurrDir% %%a in (*.DNG) do del "%%a" > nul

echo DNG_List.txt DOES NOT MATCH JPG_List.txt!
goto :EOF

echo DNG_List.txt MATCHES JPG_List.txt
goto :EOF

Another method for file deletion would depend on the %errorlevel% immediately after each pass of the FOR loop, ie. after each *.DNG image is successfully converted to a *.JPG file.

for /r "%CurrDir%" %%a in (*.DNG) do (
    echo Converting %%~nxa To %%~na.jpg ...
    %CONVERT% "%%~fa" /convert="%%~dpna.jpg"
    if errorlevel 0 del "%%a" > nul

Alternatively you could easily use the free GUI "ExamDiff.exe" text file comparison program on the two reports:


OR the retail, but very reasonably priced for its comprehensive features, "Beyond Compare":

If batch files seem too much to contend with, feel welcome to try the batch conversion from within IrfanView's user interface and see if you can set up the parameters.

Hopefully this might provide somebody else viewing this solution with an alternative method.

Thank you go4java.

Featured Post

Learn to develop an Android App

Want to increase your earning potential in 2018? Pad your resume with app building experience. Learn how with this hands-on course.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now