applescript で perl script

さて、先に準備をした gpsPhoto.pl はターミナルでコマンドラインを入力する必要がある。

./gpsPhoto.pl --dir --gpsfile --timeoffset 0

という感じだ。これを applescript を使って GUI で処理が出来るようにしてみた。実現すべきことは画像ファイルがあるディレクトリの指定とgpsファイルの指定、そして処理の実行だ。結果こんな感じになった。上の2行でそれぞれの path を取得し、最後の行で実行。'do shell script' を 'display dialog' の引数としているのは処理結果をダイアログ表示させるため。本当は処理の経過を逐次表示させたいところだが、まずはこんなもので良いだろう。

tell application "Finder"
set theFolder to POSIX path of (choose folder with prompt "Select Photo folder")
set theFile to POSIX path of (choose file with prompt "Select gpx file")
display dialog (do shell script "/Users/hogehoge/script/gpsPhoto.pl --dir " & theFolder & " --gpsfile " & theFile & " --timeoffset 0") buttons {"OK"} default button 1
end tell