私が取り組んでいるものの非常に簡単なセクションをスクリプト化するのに問題があります (私がそうなると思っていました)。基本的には、特定のアプリケーションでファイルを開くように Finder に指示したいと考えています。シンプルですね。私が読んだことから、私は使用できるはずです:
tell application "Finder"
open "the_file" using "the_application"
end tell
問題は、Finder がアプリケーションを見つけるのに一苦労しているように見えることです。次のコードを使用すると:
set webArcExtract to POSIX file (do shell script "mdfind 'WebArchive Folderizer.app' -onlyin '/Applications/'") as string #Find the Web Archive Extraction Program
tell application "Finder" #Temporary path to save the web archive
set tempPath to ((home as string) & "temp:")
end tell
tell application "Fake" #Magic that saves a webpage as a webarchive
load URL "www.google.com"
delay 3
capture web page as Web Archive saving in tempPath & "arc.webarchive"
end tell
tell application "Finder" #Open the arc.webarchive file saved in the tempPath with the WebArchive Folderizer application
open tempPath & "arc.webarchive" using webArcExtract
end tell
変数の値は次のとおりです。
tempPath: "OSX_Data:Users:user:" webArcExtract: "OSX:Applications:Utilities:WebArchive Folderizer.app"
コードを実行しようとしたときに発生するエラーは、webArcExtract 行を使用して、開いている tempPath & "arc.webarchive"で発生します。「アプリケーションが見つかりません」というメッセージが Finder からポップアップ表示されます。
私はこれに本当に困惑しています。私はパスが正しいことを知っており、アプリケーションがこの方法でファイルを開くことができることを知っています. Finder を使用して、開こうとしている arc.webarchive ファイルに移動し、ファイルを右クリックして、[開く] > [WebArchive Folderizer] を選択すると、完全に機能します。
助言がありますか?