Jump to content
  • 0

How to use applescript to create a years journal


kearney194

Idea

Here is a script for a years list of notebooks and notes


 


property theMonths : {"JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"}


property theWeekdays : {"SAT", "SUN", "MON", "TUE", "WED", "THU", "FRI"}


 


tell (current date) to set referenceDate to (it - (its day) * days + days - (its time))


 


set thisYear to year of referenceDate


 


 


set yearList to {}


repeat with i from 1 to 11


set end of yearList to (thisYear + i - 6) as string


end repeat


(* Fill year list with the previous 5 years followed by the next 5 *)


 


set chosenYear to (choose from list yearList with prompt "choose a year") as string


if chosenYear is "false" then return


(* set variable choosenyear to year picked from menu*)


set year of referenceDate to chosenYear


repeat with aMonth from 1 to 12


set month of referenceDate to aMonth


set monthnotebook to text -2 thru -1 of ("0" & aMonth) & space & item aMonth of theMonths


set currentWeekDay to weekday of referenceDate as integer


set dayList to {}


repeat with aDay from 1 to (daysInMonth for referenceDate)


set end of dayList to "/" & (text -2 thru -1 of ("0" & aDay) & "/" & chosenYear & space & "-" & space & item ((currentWeekDay mod 7) + 1) of theWeekdays)


set currentWeekDay to currentWeekDay + 1


set AppleScript's text item delimiters to ","


end repeat


repeat with the_item in dayList


tell application "Evernote"


create note title (aMonth as text) & the_item with text (aMonth as text) & the_item notebook monthnotebook


end tell


end repeat


set {TID, text item delimiters} to {text item delimiters, ","}


set dayList to dayList as text


set text item delimiters to TID


tell application "Evernote"


if (not (notebook named monthnotebook exists)) then


make notebook with properties {name:monthnotebook}


end if


end tell


end repeat


 


 


on daysInMonth for theDate -- returns an integer


copy theDate to d


set d's day to 32


32 - (d's day)


end daysInMonth


 


Link to comment

2 replies to this idea

Recommended Posts

I wanted a to create a diary folder structure.  

 

I have a folder now called 2015 and within it there are folders for each month of that year and within each of those months is a note with the date.  Video below is where I got the idea.  You have to create your stacks manually and I have since updated the script to include the year in the months folders to keep other years separate.  For clarity I have attached a zip file with a screen shot and the video really helps.  The applescript sets up folder and notes as per the second way in the video.

 

property theMonths : {"JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"}

property theWeekdays : {"SAT", "SUN", "MON", "TUE", "WED", "THU", "FRI"}

 

tell (current date) to set referenceDate to (it - (its day) * days + days - (its time))

 

set thisYear to year of referenceDate

 

 

set yearList to {}

repeat with i from 1 to 11

set end of yearList to (thisYear + i - 6) as string

end repeat

(* Fill year list with the previous 5 years followed by the next 5 *)

 

set chosenYear to (choose from list yearList with prompt "choose a year") as string

if chosenYear is "false" then return

(* set variable choosenyear to year picked from menu*)

set year of referenceDate to chosenYear

repeat with aMonth from 1 to 12

set month of referenceDate to aMonth

set monthnotebook to text -2 thru -1 of ("0" & aMonth) & space & item aMonth of theMonths & space & chosenYear

set currentWeekDay to weekday of referenceDate as integer

set dayList to {}

repeat with aDay from 1 to (daysInMonth for referenceDate)

set end of dayList to "/" & (text -2 thru -1 of ("0" & aDay) & "/" & chosenYear & space & "-" & space & item ((currentWeekDay mod 7) + 1) of theWeekdays)

set currentWeekDay to currentWeekDay + 1

set AppleScript's text item delimiters to ","

end repeat

repeat with the_item in dayList

tell application "Evernote"

create note title (aMonth as text) & the_item with text (aMonth as text) & the_item notebook monthnotebook

end tell

end repeat

set {TID, text item delimiters} to {text item delimiters, ","}

set dayList to dayList as text

set text item delimiters to TID

tell application "Evernote"

if (not (notebook named monthnotebook exists)) then

make notebook with properties {name:monthnotebook}

end if

end tell

end repeat

 

 

on daysInMonth for theDate -- returns an integer

copy theDate to d

set d's day to 32

32 - (d's day)

end daysInMonth

 

Screen shot 2014-12-25 at 10.55.55 PM.zip

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...