Home > Mac, Photography > Deleting RAW files after converting to DNG on a Mac

Deleting RAW files after converting to DNG on a Mac

August 11th, 2015 Leave a comment Go to comments

Recently, I decided to convert all my old RAW files to DNG.  This can be done from within Lightroom or with Adobe’s free DNG Converter.  In Lightroom, you have the option to have your old RAW files deleted automatically after conversion.  However, this option is unfortunately missing in the DNG Converter.

One way to do this manually is by opening a terminal session on your Mac and entering this command:

$ find [path] -name "*.[RAW extension]" -type f -delete

The above command will recursively go through all the subfolders and files under the defined path and delete all files with the defined file extension. To be safe though, you might first want to make sure that you have the same number of DNG files before deleting all the RAW files. For example:

$ find Photos/Archive/2015 -name "*.dng" -type f | wc -l
2290
$ find Photos/Archive/2015 -name "*.CR?" -type f | wc -l
2290
$ find Photos/Archive/2015 -name "*.CR?" -type f -delete

If you want to be really sure then it’s probably a good idea to first check that the DNG files are good before you delete all those RAW files. Perhaps view them all or import them to Lightroom. And when you delete all the RAW files, you might want to make sure that the converted DNG files exist. To do that I’ve written the follow shell script:

#!/bin/bash
rawfiles=$(find "$1"  -name "*.CR2" -o -name "*.ORF" | sed 's/ /\\-/g' |sed 's/CR2\\-/CR2 /g' |sed 's/ORF\\-/ORF /g')
echo Only deleting RAW files with equivalent DNG files...
for entry in $rawfiles
do
fixentry=$(echo $entry | sed 's/\\-/ /g')
dngfile=$(echo $fixentry | sed 's/...$/dng/g')
xmpfile=$(echo $fixentry | sed 's/...$/xmp/g')
if [[ -f "$dngfile" && -f "$fixentry" ]]
then
        echo Deleting $fixentry
        rm "$fixentry"
        if [[ -f "$xmpfile" ]]
        then
                echo Deleting $xmpfile
                rm "$xmpfile"
        fi
fi
done

If the script was named Delete_RAW.sh then you use it like so:

$ ./Delete_RAW.sh /Volumes/Photos/Archive/2015
Categories: Mac, Photography Tags: , ,
  1. No comments yet.
  1. No trackbacks yet.
*