Scan directly to Apple Notes (e.g. with a ScanSnap)

I’m sure this has been implemented many times but I had a hard time tracking down a simple script for it, so I’m sharing my working solution here. See the links below as well as the sample script.

Basically wanted to have a “one button scan to Apple Notes” option (scan snap official software has a “scan to Evernote” function but nothing similar for Apple Notes). Implemented it via folder actions so that any file dropped into a folder is imported to a new note as an attachment and I just point the scanning software to “save scan to folder” automatically.

Video Demo

GitHub Repo

Direct zip download from GitHub repo

(*

NAME:
Notes Inbox

SUMMARY:
Auto-import scans, images, etc. as attachments of a new note in Apple Notes by way of folder actions.
Any file dropped into the selected folder in Finder will be imported into the target folder in Apple Notes.

INSTALL:
1. Copy this script to "~/Library/Scripts/Folder Action Scripts" (or "/Library/Scripts/Folder Action Scripts")
2. In Finder, create a new folder named something like "Notes Inbox" (inside your home folder, for example)
3. Right click on new folder and choose "Services > Folder Actions Setup" (or open the setup utility directly from "/System/Library/CoreServices/Applications/Folder Actions Setup.app")
4. Allow service to run if prompted
5. Make sure "Enable Folder Actions" is checked
6. Add the new "Notes Inbox" in the left side folder list (if not already there and selected)
7. Add the "Notes Inbox" script to the right side script selection (and make sure checked)

CONFIG:
Change the "notePrefix" and "notesFolder" properties as desired.
notePrefix could be something like "Scan: " if you wish to prefix that to anything processed by this script.
notesFolder is "Inbox" by default and is the name of the folder in Apple Notes where incoming notes will be created.

CF:
https://developer.apple.com/library/archive/documentation/AppleScript/Conceptual/AppleScriptLangGuide/reference/ASLR_folder_actions.html


AUTHOR:
Ethan Schoonover
es@ethanschoonover.com
github: altercation

*)

property notePrefix : ""
property notesFolder : "Inbox"

on processFile(fileToProcess)
	set theFile to fileToProcess as text
	tell application "Finder" to set noteName to name of file theFile
	set timeStamp to short date string of (current date) as string
	set noteBody to "<body><h1>" & notePrefix & noteName & "</h1><p>Imported on: " & timeStamp & "</p></body>"
	tell application "Notes"
		if not (exists folder notesFolder) then
			make new folder with properties {name:notesFolder}
		end if
		set newNote to make note at folder notesFolder with properties {body:noteBody}
		make new attachment at end of attachments of newNote with data (file theFile)
		(*
				Note: the following delete is a workaround because creating the attachment
				apparently creates TWO attachements, the first being a sort of "ghost" attachment
				of the second, real attachment. The ghost attachment shows up as a large empty
				whitespace placeholder the same size as a PDF page in the document and makes the
				result look empty
				*)
		delete first attachment of newNote
		show newNote
	end tell
	tell application "Finder" to delete file theFile
end processFile

on adding folder items to this_folder after receiving added_items
	try
		repeat with added_item in added_items
			processFile(added_item)
		end repeat
	on error errText
		display dialog "Error: " & errText
	end try
end adding folder items to

(*
the following runs only when executing this script manually via script editor for testing purposes, simulating
incoming files by allowing the user to select a file in lieu of an actual triggered folder action
*)

processFile(choose file)

FWIW I’ve already implemented a working solution in the original post (see the github link and video demo).

Great stuff! @Rumor

I am hoping to use this to sync with various PDF editors.

Quick question,

-Is there a way to check if there is same named file already in Apple Note and update it rather than just create new?
-And instead of deleting it, could it keep the file in the folder?

Following two changes will allow various apps to be integrated with Apple Note. In my instance, it would be my E-ink tablet that auto uploads PDFs.

I think GoodNotes have auto pdf upload option as well.

Thank you @rumor! I have been looking for something like this to use with an old Doxie and now an Epson ES-50. Works great with good ole Image Capture.

Also good to see you still farting around on little projects – I’ve been using Solarized since you released it. Cheers!

Glad to hear it’s useful! I was honestly surprised there wasn’t any other built in solution for this in macOS, though it’s almost built in!