19 July 2009 by Published in: Evernote, Lifehacking 1 comment
  1. Make sure Evernote is set up to export to your documents directory (File->Print->PDF->Save PDF as…)
  2. Make sure you don’t have anything important that would match “\d+.pdf” in ~/Documents
  3. Launch evernote, highlight the notebook, highlight the first note
  4. Run the applescript below
  5. Tell it how many notes are in the notebook
set workingPath to (path to documents folder as Unicode text)
set dialogResult to display dialog ¬
	¬
		"How many times to loop?" default answer "1"
set sTimes to text returned of dialogResult
repeat with i from 1 to sTimes
	set filename to ((workingPath & i as text) & ".pdf")
	tell application "Finder"
		if exists file filename then delete filename
	end tell
end repeat

tell application "Evernote"
	activate
end tell

delay 1
repeat with i from 1 to sTimes
	tell application "System Events"
		keystroke "p" using command down
		repeat until window "Print" of process "Evernote" exists
		end repeat
		tell process "Evernote" to click menu button "PDF" of window "Print"
		tell process "Evernote" to click menu item "Save as PDF…" of menu "PDF" of menu button "PDF" of window "Print"
		repeat until window "Save" of process "Evernote" exists
		end repeat
		keystroke i as text
		keystroke (ASCII character 3)
		repeat while window "Save" of process "Evernote" exists
		end repeat
		tell application "Evernote" to activate
		keystroke (ASCII character 31)
	end tell
end repeat
set outputName to POSIX path of (workingPath & "export.pdf")
set command to "python '/System/Library/Automator/Combine PDF Pages.action/Contents/Resources/join.py' -o " & outputName

repeat with i from 1 to sTimes
	set sPath to ((workingPath & i as text) & ".pdf")
	set command to command & " " & POSIX path of sPath
end repeat
--return command
do shell script command
repeat with i from 1 to sTimes
	set filename to ((workingPath & i as text) & ".pdf")
	tell application "Finder"
		if exists file filename then delete filename
	end tell
end repeat

Want me to build your app / consult for your company / speak at your event? Good news! I'm an iOS developer for hire.

Like this post? Contribute to the coffee fund so I can write more like it.

Comments

Add comment

Copyright © 2011 Drew Crawford, All Rights Reserved
Powered by WordPress