#The following was written by Jordan Patterson and posted originally on www.JordanPatterson.me
#Feel free to modify, reuse, and repost this script
#New Dayone Entry.spct V 1.0
#This script creates a new entry in Day One with the image currently selected in Aperture attached to the entry
#This script exports the currently selected image while the script runs and then deletes it, feel free to change the location of this export from the default of the Desktop
set theExportFolder to the POSIX path of the (path to the desktop folder)
tell application "Aperture"
set imageSel to (get selection)
repeat with i from 1 to count of imageSel
tell item i of imageSel
# This script uses the EXIF date and time attached to the image to set the date and time of the Day ONe journal entry
set theYear to value of EXIF tag "CaptureYear" as integer
set theMonth to value of EXIF tag "CaptureMonthOfYear" as integer
set theDay to value of EXIF tag "CaptureDayOfMonth" as integer
set theHour to value of EXIF tag "CaptureHourOfDay" as integer
set theMin to value of EXIF tag "CaptureMinuteOfHour" as integer
set theSec to value of EXIF tag "CaptureSecondOfMinute" as integer
export imageSel using export setting "JPEG - Original Size" to theExportFolder
set image to item 1 of imageSel
tell library 1
set theName to name of image & ".jpg"
set theExportPath to theExportFolder & theName as string
set theDate to theMonth & "/" & theDay & "/" & theYear as string
set theAP to "AM"
if theMin is less than 10 then
set theMin to "0" & theMin
if theHour is greater than 12 then
set theAP to "PM"
set theHour to theHour - 12
set theTime to theHour & ":" & theMin & " " & theAP as string
set theDateTime to "\"" & theDate & " " & theTime & "\""
set theScript to "echo \"\" | /usr/local/bin/dayone -p=" & theExportPath & " -d=" & theDateTime & " new" as string
set theEntry to do shell script theScript
set theLength to the length of theEntry
set theStart to theLength - 39
set theEnd to theLength - 8
set theUDID to text theStart thru theEnd of theEntry
tell application "Safari"
set the URL of the front document to "dayone://edit?entryId=" & theUDID
do shell script "rm " & theExportPath