Skip to content

Instantly share code, notes, and snippets.

@rashita
Last active October 8, 2017 11:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rashita/8cadd4ae4d1064f7ced1 to your computer and use it in GitHub Desktop.
Save rashita/8cadd4ae4d1064f7ced1 to your computer and use it in GitHub Desktop.
Evernoteに、一日一枚のデイリーノートを、月曜日から日曜日分まで合計7枚作成するスクリプト。各ノートに「昨日」と「明日」へのノートリンクが添付される。ただし、月曜日と日曜日は、それぞれ片方だけ。
set oneWeek to {}
set newdaynote to {}
set youbiTable to ""
set sarchMonday to my (current date)
--来週の月曜日を探す
repeat 7 times
if (weekday of sarchMonday as number) is in "2" then
exit repeat
else
set sarchMonday to sarchMonday + (1 * days)
end if
end repeat
--月曜日の日付から、一週間のリスト作成する
repeat 7 times
set end of oneWeek to sarchMonday
set sarchMonday to sarchMonday + (1 * days)
end repeat
--一週間分のデイリーノートを作成
repeat with i in oneWeek
set daydate to getMonthDay(i) --日付を取得
set dayYoubi to getDayDate(i) --曜日を取得
tell application "Evernote"
set end of newdaynote to create note title (daydate & "(" & dayYoubi & ")") with text " "
end tell
end repeat
tell application "Evernote"
synchronize
end tell
tell application "Evernote"
set a to note link of (item -1 of newdaynote)
repeat
delay 3
if a is not missing value then
exit repeat
end if
set a to note link of (item -1 of newdaynote)
end repeat
end tell
tell application "Evernote"
repeat with cn from 1 to 7
set dnote to (item (cn) of newdaynote)
if cn is not 1 then
set enote to "<a href=\"" & note link of (item (cn - 1) of newdaynote) & "\">" & title of (item (cn - 1) of newdaynote) & "</a>"
else
set enote to ""
end if
if cn is not 7 then
set fnote to "<a href=\"" & note link of (item (cn + 1) of newdaynote) & "\">" & title of (item (cn + 1) of newdaynote) & "</a>"
else
set fnote to ""
end if
tell dnote to append html enote & "<br>" & fnote
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
@rashita
Copy link
Author

rashita commented Mar 8, 2015

スクリプトエディタにコピペして、「アプリケーション」形式で保存。あとは、実行するか、何かしらのアプリでHOTキーに割り当てておくのも良いです。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment