AppleScriptでFinderにApple Eventsを送信する権限がありません。(-1743)
Illustrator(Mac)ドキュメントの配置画像を収集するAppleScript をしようすると、
FinderにApple Eventsを送信する権限がありません。(-1743)のエラーがでます。
どなたか、わかる方いますか?
property myTag : "stRef:filePath" --XMPのリンクファイルタグ
global outputList
on open theFiles
repeat with afile in theFiles
my getCopyFile(afile)
end repeat
activate
display dialog "終了しました" buttons {"はい"} default button 1 with icon 1 giving up after 10
return
end open
--sedでXMPメタデータを読み込む
to getCopyFile(afile)
set input_file to (quoted form of POSIX path of contents of afile) as Unicode text --Unicode textに変換
set outputList to do shell script "echo | sed -n -e 's/^.*<" & myTag & ">\\(.*\\)<\\/" & myTag & ">/\\1/p' " & input_file
--&エラー処理
set outputList to my replaceText(outputList, "&", "&")
--書き出し
my kakidashi()
end getCopyFile
--&エラー処理
to replaceText(theText, serchStr, replaceStr)
set tmp to AppleScript's text item delimiters
set AppleScript's text item delimiters to serchStr
set theList to every text item of theText
set AppleScript's text item delimiters to replaceStr
set theText to theList as string
set AppleScript's text item delimiters to tmp
return theText
end replaceText
--書き出し
to kakidashi()
tell application "Finder"
set aText to (outputList & return)
set aTextFile to open for access ((desktop as text) & "test.txt") with write permission
set aEOF to get eof of aTextFile
try
write aText starting at (aEOF + 1) to aTextFile
on error aErrorText
display dialog aErrorText
end try
close access aTextFile
end tell
end kakidashi
iMac 21.5″ 4K, macOS 10.13