For getting pictures off my camera I use an external card reader. Unfortunately none of the applications for pulling files off there automatically do what I want, which is to move the files to a date-named directory, and automatically launch Capture One (or other app of choice), and loading the just copied files in the process.
So I figured out that in order to do this in perl you have to have a proper mac application - a plain shell script doesn't cut it sadly. So I decided to have a go at CamelBones. Once you have a proper Mac app you can tell the Image Capture preferences to use this app whenever a camera is connected (or in this case whenever my card is inserted).
It's a bit of effort to create the GUI, but I got what I needed working quite easily.
The hard part was that in order to have a progress bar you can't block the GUI "thread". So not only was this my first adventure in CamelBones, but also my first venture into perl threads.
The main thread updates the GUI with a ticker that checks for data on a queue. The "child" thread moves the files over and watches for start/cancel data on another queue.
The final piece of the puzzle was launching Capture One LE (my RAW conversion app of choice) and getting it to see the right directory. Launching was simple, but passing the directory in on the command line didn't work. So I had to resort to AppleScript, or so it seemed.
Mac::Glue to the rescue there. I've never used Mac::Glue before, but it was a good experience. Created the "stub" with the macglue command line app, and then I could just do:
my $obj = Mac::Glue->new('Capture_One_LE');
Which is really simplicity defined, compared to the ugliness of AppleScript.
Now I just need to figure out how to tell Finder to eject my card when it's finished.
If anyone wants a copy of the app to do something similar but matching their needs they are more than welcome to it.