2番煎じMEMO

「どこかで見たことあるよ」的な内容を中心に  Mac のことなど いろいろ

今日の日付をクリップボードにコピーするAppleScript

長い間 物事を放置していると、それは忘却の彼方に行ってしまい、いざやろうとしても何の事やらさっぱり訳がわからなくなります。

AppleScript もまた然り。

昔作ったものを見ても、分からない・・・。

ということで、簡単そうなものを作ってみて少しずつでも思い出していこうと「今日の日付をクリップボードにコピーする」スクリプトを作ってみました。

 

-- クリップボードに今日の日付をコピーする
set theDate to current date
set theYear to year of theDate as text
--set theGengouYear to "平成" & (((year of theDate) - 1988) as text)
set theMonth to month of theDate as integer as text
set theDay to day of theDate as text
--set theWeekday to weekday of theDate as text
set theYoubi to item (weekday of theDate as integer) of {"", "", "", "", "", "", ""}

set theText to theYear & "" & theMonth & "" & theDay & "" & "(" & theYoubi & ")"
--set theText to theGengouYear & "" & theMonth & "" & theDay & "" & "(" & theYoubi & ")"

set the clipboard to theText

 

 

「2018年3月4日(日)」ってな具合に日付をコピーします。

年号表示を和暦(平成)にするなら、年のところをコメント行と入れ替えればできます。あまり試してないので、曜日のところがダメかも?

 

(参考)

AppleScript : 日付や時刻を利用する - GameSprit