Applescript Export does nothing

I’m working on an AppleScript to export a folder of documents as PNG files. The script iterates through successfully opening and closing the documents, but no files are actually exported. Please advise.

Script content:

set folderName to POSIX path of (choose folder)
set findResults to (do shell script “find " & folderName & " -name ‘*.graffle’ | sed ‘s#//#/#’”)
set graffleFiles to every text item of splitString(findResults, return)
–“Graffle Files: " & graffleFiles
repeat with graffleFile in graffleFiles
set graffleFileP to POSIX file graffleFile
end repeat
on convertGraffleFile(graffleFileP)
tell application “OmniGraffle”
open graffleFileP
set targetFile to (do shell script “echo” & graffleFileP & " | sed ‘s#.graffle##’”)
–set targetFileP to POSIX file graffleFileP & “.png”
set targetFileP to targetFile & “.png”
log "… saving " & targetFileP
tell front document to export as “PNG” scope “current canvas” to POSIX file targetFileP
–tell front document to export as “Graffle” scope “current canvas” to POSIX path of (choose folder)
close front document
end tell
end convertGraffleFile

on splitString(theString, theDelimiter)
set oldDelimiters to AppleScript’s text item delimiters
set AppleScript’s text item delimiters to theDelimiter
set theArray to every text item of theString
set AppleScript’s text item delimiters to oldDelimiters
return theArray
end splitString

Many thanks!


Sorry for the trouble! There’s a bug in setting the scope in AppleScript currently. If you remove scope “current canvas” from both lines where it is used are you able to export?

If you go through exporting in the UI you will notice you can’t export a current canvas of an OmniGraffle document, so that’s never going to work because you can’t export just the current canvas. Entire document is the only option for OmniGraffle documents, so it won’t be possible to export just 1 canvas in that format, even after it works for PNG in the future.