Timestamp in TextEdit?

Discussion in 'Mac Apps and Mac App Store' started by Van W, May 4, 2010.

  1. Van W macrumors member

    Joined:
    Sep 5, 2009
    #1
    Is there any way to print a timestamp in TextEdit? Basically, is it possible to make a macro that does this?
     
  2. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
  3. Van W thread starter macrumors member

    Joined:
    Sep 5, 2009
    #3
    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.
     
  4. mysterytramp macrumors 65816

    mysterytramp

    Joined:
    Jul 17, 2008
    Location:
    Maryland
    #4
    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
     
  5. Van W thread starter macrumors member

    Joined:
    Sep 5, 2009
    #5
    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!
     
  6. CountMango macrumors newbie

    Joined:
    May 19, 2014
    #6
    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
     
  7. CrickettGrrrl macrumors 6502a

    CrickettGrrrl

    Joined:
    Feb 10, 2012
    Location:
    B'more or Less
    #7
    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.
     
  8. CountMango macrumors newbie

    Joined:
    May 19, 2014
    #8
    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
     
  9. CrickettGrrrl macrumors 6502a

    CrickettGrrrl

    Joined:
    Feb 10, 2012
    Location:
    B'more or Less
    #9
    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:
     
  10. kryten2 macrumors 6502a

    Joined:
    Mar 17, 2012
    Location:
    Belgium
    #10
    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
     

    Attached Files:

  11. CrickettGrrrl macrumors 6502a

    CrickettGrrrl

    Joined:
    Feb 10, 2012
    Location:
    B'more or Less
    #11
    Thank you Kind Soul. :)
     

Share This Page