ドロップレットを使用してユーザーにドロップレットにファイルをドラッグさせるのではなく、ユーザーがインストーラーをダブルクリックするだけで済むようにインストーラーを作成してみませんか? その方が簡単で、おそらく問題を回避できます。また、配送コードでエラー処理を行うのが賢明であるため、コードにエラー処理を追加しました。また、何が起こったのかをユーザーに伝えます。
注: コードにもエラーがありました。outputFolder は文字列です。Finder にはファイル指定子が必要です。文字列を指定子にするには、文字列パスの前に「ファイル」または「フォルダー」という単語を追加します。あなたのコードは機能しているかもしれませんが、それを記述する適切な方法は指定子を使用することです。他のアプリケーションは文字列パスを取らないかもしれませんが、それらはすべて指定子を取ります... したがって、文字列の代わりにそれらを使用する習慣を身につけてください。
try
-- create the output folder if necessary
set outputFolder to (path to application support folder from user domain as text) & "iWork:Pages:Templates:My Templates:"
do shell script "/bin/mkdir -p " & quoted form of POSIX path of outputFolder
-- find the templates on the dmg disk
set myPath to path to me
tell application "Finder"
set myContainer to container of myPath
set templateFiles to (files of myContainer whose name extension is "template") as alias list
end tell
-- copy the templates to the output folder
-- NOTE: the script will error if any of the templates already exist
-- therefore we use a repeat loop and duplicate each file separately with a try block
-- around it to avoid errors in case some templates have already been installed.
tell application "Finder"
repeat with aTemplate in templateFiles
try
duplicate aTemplate to folder outputFolder
end try
end repeat
end tell
-- tell the user everything was OK
tell me to activate
display dialog "The templates were successfully installed! You may now use them in Pages." buttons {"OK"} default button 1 with title "Templates Installer" with icon note
on error
tell me to activate
display dialog "There was an error installing the templates. Please manually install them by copying them to the following folder." & return & return & (POSIX path of outputFolder) buttons {"OK"} default button 1 with title "Templates Installer"
end try