-
-
Save brooksduncan/a04b95924cd8ead7cff8 to your computer and use it in GitHub Desktop.
(* | |
Scan To Apple Notes | |
Copyright (C) Brooks Duncan | |
v. 1.1 | |
You are welcome to use and modify as you see fit, but I'd appreciate credit to http://www.documentsnap.com. | |
Learn more at http://www.documentsnap.com/scan-apple-notes | |
Thank you to Larry Salibra at https://www.larrysalibra.com/evernote-to-apple-notes/. | |
*) | |
on adding folder items to this_folder after receiving added_items | |
try | |
set homeFolderPosix to (system attribute "HOME") | |
set importFolderPosix to homeFolderPosix & "/Library/Containers/com.apple.Notes/Data/scan_import/" as string | |
set importFolder to ((importFolderPosix as POSIX file) as string) | |
do shell script "mkdir -p " & quoted form of importFolderPosix | |
do shell script "rm -f " & quoted form of importFolderPosix & "*" | |
repeat with added_item in added_items | |
delay 2 | |
tell application "Finder" | |
set theFilename to name of added_item | |
move added_item to POSIX file importFolderPosix | |
end tell | |
set notesSrc to "file://" & importFolderPosix & urlEncode(theFilename) | |
set noteBody to "<html><head></head><body><img src=" & notesSrc & "></body></html>" | |
tell application "Notes" | |
make new note at folder "Notes" with properties {name:theFilename, body:noteBody} | |
end tell | |
end repeat | |
on error errText | |
display dialog "Error: " & errText | |
end try | |
end adding folder items to | |
on urlEncode(str) | |
-- Copyright 2008 ljr (http://applescript.bratis-lover.net) | |
local str | |
try | |
return (do shell script "/bin/echo " & quoted form of str & ¬ | |
" | perl -MURI::Escape -lne 'print uri_escape($_)'") | |
on error eMsg number eNum | |
error "Can't urlEncode: " & eMsg number eNum | |
end try | |
end urlEncode | |
Hi! Sorry, I'm not sure why I didn't get notified of your comment. When you say it doesn't work, what doesn't work? Was it creating a blank Note with no attachment? I've just put in a fix for that (I hope) so give it another try.
doesn't seem to work if I specify an account. It just creates a note with the name of the file, but with no attachment
tell account "[email protected]" to make new note at folder "Notes" with properties {name:theFilename, body:noteBody}
Thank you very much for this code. I am trying, without much success to create an automation that will scan from ScanSnap to Zoho Notebook. Would your script work for that if I changed the app to Notebook rather than Notes? I am migrating (slowly) from Evernote to Notebook, and while my Evernote profile works flawlessly using ScanSnap Home, I can't seem to get one working for Notebook. Any help would be much appreciated.
Great idea, just can't get it to work on OSX 10.11.4? I am not an experienced Applescript Editor, but I do code, but is the issue that the logic assumes the file is an image? If so, perhaps we could add a file test to see if it's PDF? Not sure how to do that, but willing to try.