AppleScript に「ドキュメントを開けませんでした。権限がありません。」と表示されますが、ファイルは開けますか?

AppleScript に「ドキュメントを開けませんでした。権限がありません。」と表示されますが、ファイルは開けますか?

AppleScript で複数のファイルにアクセスしようとすると、「ドキュメント [ファイル名] を開けませんでした。権限がありません」というメッセージが表示されます。ただし、これらのファイルは手動で問題なく開くことができます。

私は次のことを試みました:

  • 手動で変更された権限File->Get Info
  • ディスクユーティリティを使用して「検証」および「アクセス権の修復」を実行しました
  • ホームディレクトリの権限と ACL をリセットするためにリカバリモードで再起動しました

問題は引き続き発生しています。

さらにイライラさせられるのは、ファイルが常にエラーを報告しないということです。スクリプトを実行したときにファイルにエラーが発生することもありますが、次回は発生しません。

この権限エラーが発生するのはなぜでしょうか。また、他にどのような対処方法がありますか。

役に立つかどうかは、以下の AppleScript を参照してください。

-- prompt for source directory
set srcDirectory to (choose folder)

-- get list of all files in source directory
set allFiles to (list folder srcDirectory without invisibles)

tell application "OmniGraffle"
    -- create a new document
    set newDocument to (make new document with properties {template:"Single Pixel Grid"})

    -- added for debug purposes
    delay 5

    -- get a reference to the first layer
    set destinationLayer to first layer in first canvas of newDocument

    -- step through each of the file
    repeat with currentFile in allFiles
        -- get a reference to the next file
        set srcFileString to (srcDirectory as string) & currentFile
        set srcFileRef to (open srcFileString)

        -- get a reference to the icon
        set srcGraphic to first graphic in first layer in first canvas of srcFileRef

        -- flip the icon (they're all upside down)
        flip srcGraphic over vertically

        -- copy the updated source to destination canvas
        duplicate srcGraphic to destinationLayer

        -- close the source file
        close srcFileRef saving no

        -- added for debug purposes
        delay 5
    end repeat

end tell

関連情報