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

관련 정보