【Apple Script】引数で文字列を受け取るときは注意!

Apple Script の 起動時に、文字列の引数を受け取る場合、

以下のように書くと、文字列として認識しない場合があった。

on run argv
    set text1 to item 1 of argv

「as text」でキャストしてあげると文字列として認識した。

on run argv
    set text1 to item 1 of argv as text

Automator → シェルスクリプト 実行 → Apple Scriptファイル 起動 → OK

Automator → Apple Script 実行 → NG