Archive for the ‘Mac’ Category

Changing created/modify date of DNG files

August 16th, 2015 No comments

A “problem” I noticed when converting my RAW files to DNG is that the file creation date of the DNG files is the date the conversion was done. I would prefer if the creation date was the same date as when the photos were taken. As it turns out, you can easily change the creation date of a file by simply executing the following terminal command (Mac/Linux):

$ touch -t [YYMMDDHHMM] [filename]

This is fine except how do you know when a photo was taken? You could go to Lightroom (or some other application) to check but I prefer a command line interface. One excellent tool for this is ExifTool. This tool is so awesome that it’s even used by various commercial applications. In fact, I didn’t have to install this tool because it’s already bundled with Affinity Photo.

Once you have ExifTool, you can check the date the photo was taken by executing:

$ exiftool -createdate [filename]

Okay, now we can check the date the photo was taken and update the creation date of the file. But this isn’t easy to do manually for lots and lots of newly converted DNG files. So I’ve made a script to do it automatically for all DNG files found under a defined path:

dngfiles=$(find "$1" -name "*.dng" | sed 's/ /\\-/g' | sed 's/dng\\-/dng /g')
for entry in $dngfiles
fixentry=$(echo $entry | sed 's/\\-/ /g')
output=$(/Applications/Affinity\ -createdate "$fixentry" | grep Create | sed s/://g | sed s/\ //g | sed 's/^CreateDate//' | sed 's/..$//')
touch -t $output "$fixentry"
ls -l "$fixentry"

Let’s say we call the script To run the script, you simply give the path to check. For example:

$ ./ /Volumes/Photos/Archive/2015
Categories: Mac, Photography Tags: , ,

Deleting RAW files after converting to DNG on a Mac

August 11th, 2015 No 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
$ find Photos/Archive/2015 -name "*.CR?" -type f | wc -l
$ 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:

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
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" ]]
        echo Deleting $fixentry
        rm "$fixentry"
        if [[ -f "$xmpfile" ]]
                echo Deleting $xmpfile
                rm "$xmpfile"

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

$ ./ /Volumes/Photos/Archive/2015
Categories: Mac, Photography Tags: , ,

Useful keys on a MacBook Air with Finnish keyboard

November 24th, 2012 6 comments

Wow, it’s been two and a half years since my last post.  I don’t think blogging is my thing.  I think and plan too much about what to write and then never get around to it.  So instead, I think I’ll just use this space to write down stuff so I don’t forget.

For example, I can never remember how to type pipes or square brackets on my MacBook Air.  A quick Google doesn’t really help as it seems to be different on my Finnish keyboard.  So here’s a list of keys that I think are useful to know:

Pipe (|) = Alt + 7
Backslash (\) = Shift + Alt + 7
Open square bracket ([) = Alt + 8
Closed square bracket (]) = Alt + 9
Open curly bracket ({) = Shift + Alt + 8
Closed curly bracket (}) = Shift + Alt + 9
Dollar sign ($) = Alt + 4
Tilde (~) = Alt + ¨

Page up = Fn + Up
Page down = Fn + Down

Print screen = Cmd + Shift + 3
Partial print screen = Cmd + Shift + 4 (You get a cursor to select what to capture)
Print window = Cmd + Shift + 4 and then press Spacebar

Delete = Fn + Backspace
Delete file from Finder = Cmd + Backspace

Categories: Mac Tags: , , , ,