Evernoteに365日分のデイリーノートを作成するAppleScript
汎用ではなく、私用になっています。
少なくとも、settemp()の中身は、作りたいデリイーノートに合わせて書き換えて使ってください。
code:apple.scpt
--一月一日を設定する
set newday to (current date)
tell newday to set {year, day, month of it, day, time} to {2019, 1, January, 1, 0}
--一年分の日付をリストにする
set YearDayList to {}
repeat 365 times
set end of YearDayList to newday
set newday to newday + (1 * days)
end repeat
--一年分のデイリーノートを作成
set newYearEvernoteList to {} --一年分のEvernoetのリスト
repeat with i in YearDayList
set daydate to getMonthDay(i) --日付を取得
set dayYoubi to getDayDate(i) --曜日を取得
tell application "Evernote"
set end of newYearEvernoteList to create note title ("📅" & daydate & "(" & dayYoubi & ")") with text " "
end tell
end repeat
--Evernoteを同期する
tell application "Evernote"
synchronize
end tell
--デイリーノートのテンプレートを取得
set daynotetemp to ""
set daynotetemp to my settemp()
--一番最後のノートのノートリンクが取得できるまで次に進まない
tell application "Evernote"
set a to note link of (item -1 of newYearEvernoteList)
repeat
delay 3
if a is not missing value then
exit repeat
end if
set a to note link of (item -1 of newYearEvernoteList)
end repeat
end tell
--各デイリーノートにノートリンクを貼り付けていく
tell application "Evernote"
repeat with cn from 1 to 365
set dnote to (item (cn) of newYearEvernoteList)
if cn is not 1 then
set enote to "<a href=\"" & note link of (item (cn - 1) of newYearEvernoteList) & "\">" & title of (item (cn - 1) of newYearEvernoteList) & "</a>"
else
set enote to ""
end if
if cn is not 365 then
set fnote to "<a href=\"" & note link of (item (cn + 1) of newYearEvernoteList) & "\">" & title of (item (cn + 1) of newYearEvernoteList) & "</a>"
else
set fnote to ""
end if
tell dnote to append html enote & "_" & fnote & "<br />" & daynotetemp
set aTag to tag "diary"
assign aTag to dnote
set creation date of dnote to item (cn) of YearDayList
end repeat
end tell
--データを渡したら、曜日のタグを返すサブルーチン
on getDayDate(theDate)
set d to (weekday of theDate as number)
-- set dayList to {"<font color=\"#E82E0F\">日</font>", "月", "火", "水", "木", "金", "<font color=\"#46D7E5\">土</font>"}
set dayList to {"日", "月", "火", "水", "木", "金", "土"}
repeat with i from 1 to 7
if i is d then
return (item i of dayList)
exit repeat
end if
end repeat
end getDayDate
--データを渡したら、○月○日で返すサブルーチン
on getMonthDay(theDate)
set y to (year of theDate)
set m to my monthNumStr(month of theDate)
set d to day of theDate
return (m & "月" & d & "日") as text
end getMonthDay
--month of dete から数字の月を返す。
on monthNumStr(theMonth)
set monList to {January, February, March, April, May, June, July, August, September, October, November, December}
repeat with i from 1 to 12
if item i of monList is theMonth then exit repeat
end repeat
return i
end monthNumStr
--デイリーページのテンプレート
on settemp()
display dialog "ok"
return "<table style=\"border-collapse: collapse; min-width: 100%;\"><colgroup><col style=\"width: 388px;\" /><col style=\"width: 388px;\" /></colgroup><tbody><tr><td style=\"background-color: rgb(231, 132, 86); border: 1px solid rgb(185, 106, 69); width: 388px; padding: 8px;\"><div></div><div><a href=\"evernote:///view/000000/s0/000000-00000000/\"><font color=\"#000000\">2019年総合カレンダー</font></a></div></td><td style=\"border: 1px solid rgb(185, 106, 69); background-color: rgb(231, 132, 86); width: 472px; padding: 8px;\"><div><br/></div></td></tr><tr><td style=\"border: 1px solid rgb(204, 201, 188); background-color: rgb(255, 251, 235); width: 256px; padding: 8px;\"><div>起床</div><div><br/></div><div><br/></div><div><br/></div><div><br/></div><div><br/></div><div><br/></div><div><br/></div><div><br/></div><div><br/></div><div><br/></div><div><br/></div><div><br/></div><div><br/></div><div><br/></div></td><td style=\"border: 1px solid rgb(204, 201, 188); background-color: rgb(255, 251, 235); width: 472px; padding: 8px;\"><div><br/></div></td></tr><tr><td style=\"border: 1px solid rgb(204, 201, 188); background-color: rgb(255, 251, 235); width: 728px; padding: 8px;\" colspan=\"2\"><div>今日のノート</div><div><br/></div><div><br/></div><div><br/></div><div><br/></div><div><br/></div><div><br/></div><div><br/></div><div><br/></div><div><br/></div><div><br/></div><div><br/></div></td></tr></tbody></table>"
end settemp