Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Van W

macrumors member
Original poster
Sep 5, 2009
30
0
Is there any way to print a timestamp in TextEdit? Basically, is it possible to make a macro that does this?
 
Yes, with AppleScript.

Ok, I figured out how to make a service that puts the timestamp into the Clipboard...which I can then simply paste. But how do you make it simply print the timestamp without having to paste?


edit: never mind, figured it out. here's the script for anyone who wants to do this (remember to make the new script as a "service", set input as "none", and then when you're done, set a keyboard shortcut):



on run {input, parameters}
set the clipboard to ((current date) as text)

tell application "System Events"
keystroke "v" using command down
end tell

return input
end run





The output looks like this:
Tuesday, May 4, 2010 11:14:50 PM

Interestingly, you can save the service in "All Applications", as opposed to just "TextEdit". Whenever you use it, it will print the timestamp wherever the cursor happens to be at that moment.
 
You might want to take a look at WordService. It has a number of useful text manipulations (including inserting date and time). It's old -- from 2007 -- but it's survived my upgrades from Tiger to Leopard and Leopard to Snow Leopard.

mt
 
You might want to take a look at WordService. It has a number of useful text manipulations (including inserting date and time). It's old -- from 2007 -- but it's survived my upgrades from Tiger to Leopard and Leopard to Snow Leopard.

mt

Thanks for the tip. I loaded it and it appears to be working. The service "Long Date and Time" has the same output as my script.

It was interesting to learn more about AppleScript, though!
 
Help Required

Hi,
I see that your technique is the solution to my problem, but I know nothing about Apple Script. So pls, pls write step by step instructions if you can.
It will be a great help.
CountMango
 
Hi,
I see that your technique is the solution to my problem, but I know nothing about Apple Script. So pls, pls write step by step instructions if you can.
It will be a great help.
CountMango

Hi CountMango,

I tried cutting & pasting the Applescript but didn't get it to work, however, MysteryTramp's WordService link is great. It's old but it works in Mavericks, I was able to insert a timestamp in TextEdit yay! Seriously, the lack of one before this was so annoying.

Download & unzip the WordService file, open the folder. Then in another Finder window go to your Home folder/Library/Services and drag the WordService.service file into that folder.

You may have to go to System Preferences/Security & Privacy/General and allow apps downloaded from Anywhere, temporarily.

Then while in SysPrefs pane, go to Keyboard/Shortcuts tab, click on Services in the left window pane and in the right window pane check the boxes for Long Date, and/or Long Date & Time.

When you open TextEdit, click on TextEdit in the menu bar, then Services, then Long Date. Presto, there it is in the document.

Long date doesn't show a keyboard shortcut, but Long Date with Time's shortcut (Command Shift %) works. I can add a shortcut for the other one later.
 
Thanks CrickettGrrrl!
It works perfectly fine.
Although I would really appreciate if you could somehow post the method along with the actual lines of code to be entered while creating a script for the same outcome.
Thanks again.
CountMango
 
Thanks CrickettGrrrl!
It works perfectly fine.
Although I would really appreciate if you could somehow post the method along with the actual lines of code to be entered while creating a script for the same outcome.
Thanks again.
CountMango

I wasn't able to add the timestamp through an applescript, I had to use the pre-made WordService file. Sorry, I'm not a coder, nor a good cook. Although I can follow clear instructions the timestamp applescript eludes me. :eek:
 
Thanks CrickettGrrrl!
It works perfectly fine.
Although I would really appreciate if you could somehow post the method along with the actual lines of code to be entered while creating a script for the same outcome.
Thanks again.
CountMango

I wasn't able to add the timestamp through an applescript, I had to use the pre-made WordService file. Sorry, I'm not a coder, nor a good cook. Although I can follow clear instructions the timestamp applescript eludes me. :eek:

Howto create the Service :

  1. Open Automator
  2. Choose to create a Service
  3. Service receives no input in any application or TextEdit
  4. Drag Run Applescript action into worflow
  5. Paste code into the Run Applescript action
  6. Save service
  7. Done
 

Attachments

  • Screen Shot 2014-05-19 at 19.49.31.png
    Screen Shot 2014-05-19 at 19.49.31.png
    283.6 KB · Views: 565
  • Screen Shot 2014-05-19 at 19.52.22.png
    Screen Shot 2014-05-19 at 19.52.22.png
    234.6 KB · Views: 598
  • Screen Shot 2014-05-19 at 19.52.39.png
    Screen Shot 2014-05-19 at 19.52.39.png
    235.1 KB · Views: 641
  • Screen Shot 2014-05-19 at 19.53.54.png
    Screen Shot 2014-05-19 at 19.53.54.png
    354.4 KB · Views: 580
  • Screen Shot 2014-05-19 at 19.54.59.png
    Screen Shot 2014-05-19 at 19.54.59.png
    52.9 KB · Views: 512
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.