Automating Adobe Dng Converter In Windows

Automating Adobe DNG converter in Windows

Read Post
Automating Adobe Dng Converter In Windows

First posted 2018-09-25

A few years back, I decided to standardize my raw photo archive into the Adobe DNG format. I’ve had a few different brands of camera and negative scanners over the years, and I’m not confident all the different formats will be readable decades from now. Also, I started using Google Photos, which does not support most of them, so treats most raw pictures like unknown data files. Fortunately, it does support DNG. These will be do not count towards your Google Drive storage limits and will be displayed on the Photos UI just like JPEGs would.

Building a workflow

Adobe publishes a utility called Adobe Digital Negative Converter. It can convert to DNG from any format which is supported by Camera RAW. It works OK, but it does seem a bit like a reference implementation, just to get people to adopt the format. Up until now I have been manually selecting files to convert from my SD card and exporting them to my “unsorted” archive directory, ready for manual editing, sorting etc. Then, I have to go and delete all the source files for all converted images. Really I wanted to do all this with a single click, each time I inserted my SD card, but it does not support this directly. Fortunately, it does have some simple command line arguments. These are not enough in themselves, because wildcards are not supported for input file specifications, but I figured PowerShell could step in here…

A Powershell script



Here’s a script which does exactly what I wanted. You will need to change the first three lines to specify your SD card path, destination root directory and source file extension. It will create a new directory in there with today’s date, dump the converted files there, and delete the source files if the conversion was successful. This seems faster and less error-prone than my old manual approach.

$sourceDir = "E:\DCIM\"
$outputRoot = "D:\OneDrive\Images\Unsorted" 
$sourceFileSpec = "*.rw2"
$dngExePath = "C:\Program Files\Adobe\Adobe DNG Converter\Adobe DNG Converter.exe"
$outputDir = "$outputRoot\$(get-date -f yyyy-MM-dd)"
$baseArgs = "-d " + """$outputDir""" + " "
$sourceFiles = Get-ChildItem -Path $sourceDir -Recurse -Include $sourceFileSpec
if ($sourceFiles.Count -gt 0)
    New-Item -ItemType Directory -Force -Path $outputDir
ForEach ($file in $sourceFiles) {
    $fullArgs = $baseArgs + """$file"""
    $process = start-process $dngExePath $fullArgs -Wait -PassThru
    if ($process.ExitCode -eq 0)
        Remove-Item -path $file

You’re free to use and adapt this script as you like. I would love to hear about it.

Finishing touches

To run this script from the start menu, you need to create a shortcut which will execute it. Windows makes it a little harder to do this that you might think, probably in an effort to make it harder for malware authors to use PowerShell as a vector. The shortcut will need a command line like this:

powershell.exe -ExecutionPolicy Bypass -File "D:\Scripts\Import to DNG.ps1"

That will override the default execution policy, which does not allow scripts. Now you just have to right-click on the shortcut and choose Pin to Start Menu.

Future improvements

This script could also move over new movie files to their archive locations. It should probably delete any XMP (sidecar) files associated with the image files it deletes. These would be created if you had edited any of the files directly on the SD card from Camera Raw.

It’s probably possible to get it to run automatically whenever you insert the relevant SD card, but I’m not sure I would want that myself.

Hamish Barjonas

Creator of custom software for TV and live production. Maker, home automation, audio and video enthusiast.