Thursday, May 19, 2005

Moblogging

I'm using a new phone that happens to have a camera. For my next phone purchase I was considering getting a camera phone so I'm playing with this camera to see how much I'd actually use one. Pictures kept on the phone are only so useful--displaying a contact's picture when they call or what not. What I really want is to share the pictures with others in Flickr. I can email pictures, one by one, from the cellphone but this is tedious and expensive on my plan. I began playing with the new Automator application in Mac OS X Tiger. My experience was not pleasant. The UI is far from snappy and my end result didn't work. The workflow produces the expected results when run from within Automator but not when saved as a plug-in or application. Instead, AppleScript did the trick. The script below will open Nokia Collector (works with my SonyEricsson), grab my latest pictures over Bluetooth, browse the folder of downloaded images looking for JPG images with a certain name (that my phone uses), and email those images as attachments.

on run
tell application "Nokia Collector"
activate
delay 30
quit
end tell
set photosFolder to "OCL PB3:Users:mhdavids:Library:Application Support:Nokia Collector:Library:00-0e-07-1e-04-d9"
tell application "Mail"
set newMessage to make new outgoing message with properties {subject:"title", content:"description" & return & return}
tell newMessage
set sender to "my@address.com"
make new to recipient at end of to recipients with properties {address:"e@mail.com"}
tell content
set photos to list folder photosFolder without invisibles
repeat with i from 1 to (count of photos)
set strFile to ((photosFolder & ":" & item i of photos) as string) as alias
set recFileInfo to info for strFile
if (not folder of recFileInfo) then
set strFileName to name of recFileInfo
if ((strFileName contains "Moblog") and (strFileName contains "jpg")) then
make new attachment with properties {file name:strFile}
end if
end if
end repeat
end tell
end tell
send newMessage
end tell
end run

It's pretty rough but it gets the job done.

No comments: