Never Stop Building - Crafting Wood with Japanese Techniques

View Original

AppleScript for Pasting the Current Date

Author’s Note! This article has been imported from my previous website. I wanted to preserve all of the old content as many people have found some value in it. There may be some broken links and or formating issues. If something isn’t right, please let me know and I’ll do my best to make an update.

I’m a big fan of taking notes with Evernote and wanted a way to paste the current date time into the note, or for that matter into anything I was working on.

Installation

The basic instructions for getting this setup can be found here.

Making the workflow

Create a simple service in Apple Automator that receives no input in any application, save it as something like "paste_date":

The Code

Here is the code I used:

set newTxt to ((current date) as string) 
set the clipboard to newTxt 
tell application "System Events" to keystroke "v" using {command down}

Creating the Shortcut

In the Keyboard Preferences create a new shortcut for this service:

That’s it! Now in any application you can just press command-shift-d and paste the date:

Thursday, January 5, 2012 10:47:22 AM