Hi,
i’am a Noobie on this forum and in the Applescript.
Recently, I wrote a script that stores the Notes attachment to a file on disk. Script works fine on all later OS X versions except of 10.11. I think I have a problem with some kind of sand-boxing limitations of Notes.app on El Capitan.
This is applescript code example:
set homeFolderPosix to (system attribute "HOME")
-- Sandboxing limits access to Notes.app' own container. This location works up to Yosemite
set tmpExportFolderPosix to homeFolderPosix & "/Library/Containers/com.apple.Notes/Data/tmp_exported/" as string
--set tmpExportFolderPosix to homeFolderPosix & "/Library/Containers/com.apple.Notes.HTMLConverter/Data/tmp_exported/" as string
set tmpExportFolder to ((tmpExportFolderPosix as POSIX file) as string)
do shell script "mkdir -p " & quoted form of tmpExportFolderPosix
-- Clean out any attachments that may be left over from previous failed run
do shell script "rm -f " & quoted form of tmpExportFolderPosix & "*"
set attCounter to 0
tell application "Notes"
tell account "On My Mac" to tell folder "Notes" to set theNote to note "TEST123"
set theAttachs to every attachment of theNote
if (count of theAttachs) > 0 then
repeat with att in theAttachs
set attCounter to attCounter + 1
set attFName to attCounter & "_" & (name of att) as string
set attFile to ((tmpExportFolderPosix & attFName) as string)
save att in attFile
end repeat
else
log ("No attachments found in the " & noteTitle & " note!")
end if
end tell
Does anyone know correct location where is allowed to save a file with the attachment?
Thanks!