Author Topic: Script for automatic multiple instances of CR2HDR (Mac)  (Read 2765 times)


  • Just arrived
  • *
  • Posts: 1
Script for automatic multiple instances of CR2HDR (Mac)
« on: July 06, 2014, 02:10:05 PM »

Seeing that CR2HDR takes some time to process and I wasn't happy letting my 6 core mac pro process this with a single thread i did some research on how to enable multiprocessing.

I came to the windows technique of launching multiple processes and devised something similar for Mac OS X;

Here is what I propose:

1) create a folder where you like dedicated to converting CR2 Dual ISO files
2) create an AppleScript file with the below contents, and put it in the folder called /Library/Scripts/Folder Actions Scripts
Code: [Select]
-- list of processed extensions: only CR2 for now, avoids processing DNG if you leave them there.
property extension_list : {"cry"}

-- CR2HDR binary filepath: to be adjusted to your own setup:
property cr2hdrBin : "/Users/olivier/Public/cr2hdr"

on adding folder items to this_folder after receiving these_items
repeat with i from 1 to number of items in these_items
set this_item to item i of these_items
set the item_info to the info for this_item
if (the name extension of the item_info is in the extension_list) then
end if
end repeat
on error error_message number error_number
if the error_number is not -128 then
tell application "Finder"
display dialog error_message buttons {"Cancel"} default button 1 giving up after 120
end tell
end if
end try
end adding folder items to

-- this sub-routine processes files
on process_item(source_file)

set the source_item to the quoted form of the POSIX path of the source_file
-- note the  '& "&> /dev/null &"' that allows to launch and forget the converter, omitting this means you need to wait for the end of processing to start the next.
-- also remember to change the path to CR2HDR to match your own setup.
                do shell script (cr2hdrBin & " " & source_item & " &> /dev/null &")
on error error_message
tell application "Finder"
display dialog error_message buttons {"Cancel"} default button 1 giving up after 120
end tell
end try
end process_item

3) right click on your folder and choose "Folder Action Setup..." to assign an action script to this folder, and choose the script you just created, so that any file dropped in this folder will undergo conversion by CR2HDR automatically.

Now your conversion workflow is to drop the CR2 files from the memory card to this folder, and then you can post-process in your regular RAW file processor.

The only problem I have is that this script will start as many processes as there are files - i would rather have it capped to 12 threads for my 6 cores but I don't know how to do this.
If anyone can propose a solution for this that would be great.

Another point is you could want to delete the files after processing, which would be possible by adding a second shell script command to remove the file.