Estou obtendo um "O documento [filename] não pôde ser aberto. Você não tem permissão" ao tentar acessar vários arquivos em um AppleScript. No entanto, posso abrir esses arquivos manualmente sem problemas.
Eu tentei o seguinte:
File->Get Info
Continuo com o problema.
Para adicionar mais frustração, os arquivos não reportam consistentemente o erro. Às vezes, recebo o erro em um arquivo quando o script é executado, mas não da próxima vez!
Por que eu recebo esse erro de permissão e como mais posso resolvê-lo?
AppleScript abaixo, se isso ajudar:
-- 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