Knowledge Base

Preserving for the future: Shell scripts, AoC, and more

Convert .dng to .jpg

I had a batch of .dng files that should be converted to .jpg format. I tried a few ways, but they did not preserve all the exif metadata. My process documented below does.

  1. Use Irfanview to batch convert all .dng files to .jpg. This will strip a lot of the metadata.

  2. Add in metadata from original file.

    time for word in *dng ; do exiftool -all= -tagsfromfile "${word}" -exif:all "${word%%.dng}.jpg" ; done

This command syntax is verbatim from the man page for exiftool.

  1. Apply original timestamp.

    for word in *dng ; do touch --no-create --reference "${word}" "${word%%dng}jpg" ; done

  2. Optionall, remove the original files.

    rm $( for word in *.jpg ; do echo "${word%%.jpg}.dng" ; done ; )

References

Man pages

  1. exiftool(1p)

Comments