Skip to content

Instantly share code, notes, and snippets.

@ChewingPencils
Created March 19, 2013 22:07
Show Gist options
  • Save ChewingPencils/5200578 to your computer and use it in GitHub Desktop.
Save ChewingPencils/5200578 to your computer and use it in GitHub Desktop.
Prepend creation date to Evernote title and append creation date to Evernote body. #applescript
--
-- Created by: Sean Korzdorfer
-- Created on: 03/19/13 15:01:44
--
-- Copyright (c) 2013 MyCompanyName
-- All Rights Reserved
--
tell application "Evernote"
set selectedNotes to selection
repeat with theNote in selectedNotes
set cDate to creation date of theNote
set theDate to my get_date(cDate)
set noteHTML to (HTML content of item 1 of theNote)
-- Prepend to Evernote note
-- set (HTML content of item 1 of theNote) to "Date: " & theDate & "<br/><br/><br/>" & noteHTML
set tDate to my get_just_date(cDate) as string
set theTitle to the title of theNote
set the title of theNote to tDate & " - " & theTitle
append theNote text return & return & "----" & return & "Date: " & theDate
end repeat
end tell
on get_just_date(theDate)
set theMonth to my zeroPad(month of theDate as integer)
set theDay to my zeroPad(day of theDate)
set theYear to year of theDate
return (theYear & "-" & theMonth & "-" & theDay)
end get_just_date
on get_date(theDate)
set theMonth to my zeroPad(month of theDate as integer)
set theDay to my zeroPad(day of theDate)
set theYear to year of theDate
set theTime to my convert_time(time of (theDate))
return (theYear & "-" & theMonth & "-" & theDay & " " & theTime) as string
end get_date
on convert_time(theTime)
set theHour to my zeroPad(round (theTime / hours) rounding down)
set theMinute to my zeroPad(round ((theTime mod hours) / minutes) rounding down)
set theSecond to my zeroPad(round (((theTime / minutes) - result) * 60) rounding down)
return theHour & ":" & theMinute & ":" & theSecond
end convert_time
on zeroPad(thisNumber)
return text -2 thru -1 of ("0" & thisNumber)
end zeroPad
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment