Skip to content

Instantly share code, notes, and snippets.

View swbuehler's full-sized avatar

Steven Buehler swbuehler

View GitHub Profile
tell application "Evernote"
set theDate to (the (current date) - the (time of the (current date)))
-- Today's applications
do shell script "echo " & quote & "Applied Today:" & quote & " > ~/Jobs.txt"
set theNotes to every note in notebook "Job Search" whose creation date ≥ theDate
repeat with eachNote in theNotes
set theTitle to the title of eachNote
tell application "Evernote"
set receipts to every note of notebook "Receipts"
repeat with receipt in receipts
set theNoteTitle to the title of receipt
set theYear to the first word of theNoteTitle
set theMonth to the second word of theNoteTitle
set theDay to the third word of theNoteTitle
set theTime to the fourth word of theNoteTitle
set theHour to characters 1 thru 2 of theTime as string
if theHour < 12 then
tell application "System Events"
tell application "iTunes"
set the clipboard to "Listening to "
if the class of the current playlist is (radio tuner playlist) then
set the clipboard to (the clipboard) & ¬
quote & the current stream title & quote & ¬
" on the " & quote & the name of the current track & quote & ¬
" stream"
else
if the podcast of the current track is true then
@swbuehler
swbuehler / gist:5021757
Created February 23, 2013 23:06
Get Evernote information into a Word Table (Example)
tell application "Evernote"
tell application "Microsoft Word"
set theDocument to active document
set theTable to make new table at theDocument with properties {number of rows:1, number of columns:2}
set content of text object of (get cell from table theTable row 1 column 1) to "Date"
set content of text object of (get cell from table theTable row 1 column 2) to "Job Description"
insert rows selection position below number of rows 1
set rowNumber to 2
end tell
set theNotes to every note in notebook "Job Search"
@swbuehler
swbuehler / gist:6357013
Created August 27, 2013 18:12
Remove file extension from evernote note titles (example)
tell application "Evernote"
set theNotebooks to every notebook
repeat with eachNotebook in theNotebooks
set theNotes to every note in eachNotebook
repeat with eachNote in theNotes
set theoldTitle to the title of eachNote
if the length of theoldTitle > 4 then
set theEnding to characters -4 thru -1 of theoldTitle as string
if theEnding is ".pdf" then
set theNewTitle to characters 1 thru -5 of theoldTitle as string
tell application "Evernote"
set theNotebooks to every notebook
repeat with eachNotebook in theNotebooks
set theNotes to (every note in (eachNotebook) whose creation date is greater than or equal to (the (current date) - the (time of the (current date)) - 1 * weeks))
repeat with eachNote in theNotes
set theTitle to the title of eachNote
try
set dateflag to 1
set theMonth to word 2 of theTitle as integer
tell application "Evernote"
set theDate to (the (current date) - the (time of the (current date)))
-- Today's applications
do shell script "echo " & quote & "Applied Today:" & quote & " > ~/Jobs.txt"
set theNotes to every note in notebook "Job Search" whose creation date ≥ theDate
repeat with eachNote in theNotes
set theTitle to the title of eachNote
@swbuehler
swbuehler / Update Creation Dates.scpt
Last active December 29, 2015 13:29
Evernote: Update creation dates based on information in note title
tell application "Evernote"
set theNotes to the selection
repeat with eachNote in theNotes
set dateflag to 0
set theTitle to the title of eachNote
if theTitle begins with "DOS" and theTitle ends with "(Notes)" then -- for Medical Notes (DOS yyyy-mm-dd ... (Notes))
try
set the creation date of eachNote to date (do shell script "date -j -f '%F' " & quote & (characters 5 thru 14 of theTitle as string) & quote & " +'%A, %B %d, %Y at %r'")
set dateflag to 1
end try
@swbuehler
swbuehler / gist:8407295
Created January 13, 2014 20:17
Parse filename and add keywords to PDF file (sample) using exiftool
tell application "Finder"
set theFolder to alias "Mac mini:Users:steven:SkyDrive:Receipts"
set thePDFs to every file in theFolder
repeat with eachPDF in thePDFs
try
set theFileName to the name of eachPDF
set theDate to (text 6 thru 7 of theFileName) & "/" & (text 9 thru 10 of theFileName) & "/" & (text 1 thru 4 of theFileName)
set theVendor to text 19 thru ((offset of "$" in theFileName) - 2) of theFileName
set theAmount to text (offset of "$" in theFileName) thru ((offset of ".pdf" in theFileName) - 1) of theFileName
set theKeywords to (quote & "vendor=" & theVendor & ", date=" & theDate & ", amount=\\" & theAmount & quote) as text
@swbuehler
swbuehler / gist:8947169
Created February 12, 2014 00:06
WordPress XML to Evernote Items
tell application "System Events"
set rssFeed to XML file "Mac mini HD:Users:steven:Downloads:stevenwbuehler.wordpress.2014-02-09.xml"
set rssItems to every XML element of XML element "channel" of XML element "rss" of contents of rssFeed whose name is "item"
repeat with thisItem in rssItems
set theTitle to the value of XML element "title" of thisItem
set thepubDate to the value of XML element "pubDate" of thisItem
set theContent to the value of XML element "content:encoded" of thisItem
tell application "Evernote"
create note notebook "Blog Temp" with html theContent title theTitle created date (do shell script "date -j -f '%a, %d %b %Y %H:%M:%S %z' " & quote & thepubDate & quote & " '+%A, %B %d, %Y at %r'")
end tell