Create Keyboard Shortcut to insert Today’s Date

Posted on 25 October 2011 • AppleBlogTechnology

I work on new little projects almost everyday for my clients. I like to organise the projects in a folder by date so I can easily find them later, so I created a Mac OS X Keyboard Shortcut to insert Today’s Date.

1. Launch the Mac OS X Automator application.

2. Create a new Service document.

3. Add a Run Applescript action to the document.

4. Paste in the following script to insert today’s date in the format YYYY-MM-DD:

on run
set {year:y, month:m, day:d} to (current date)
set ymd to (y * 10000 + m * 100 + d) as string
set date_ to (text items 1 thru 4 of ymd as string) & "-" & (text items 5 thru 6 of ymd as string) & "-" & (text items 7 thru 8 of ymd & " " as string)
set the clipboard to date_ as text
tell application "System Events" to keystroke (date_)
end run

5. Select File > Save and name the file Insert Today’s Date.workflow to save it to your ~userLibraryServices folder.

6. Open System Preferences > Keyboard preferences and select the Keyboard Shortcuts tab.

7. Locate the script Insert Today’s Date under the Services pane.