Skip to content

Instantly share code, notes, and snippets.

@brooksduncan
Last active September 14, 2023 15:41
Show Gist options
  • Save brooksduncan/a04b95924cd8ead7cff8 to your computer and use it in GitHub Desktop.
Save brooksduncan/a04b95924cd8ead7cff8 to your computer and use it in GitHub Desktop.
ScanSnap Scan To Apple Notes
(*
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
@Rockin52
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment