Re: Applescript Date Manipulation...
Re: Applescript Date Manipulation...
- Subject: Re: Applescript Date Manipulation...
- From: "Marc K. Myers" <email@hidden>
- Date: Fri, 20 Dec 2002 23:55:20 -0500
Date: Fri, 20 Dec 2002 18:00:16 -0800
Subject: Applescript Date Manipulation...
From: "Domains4Days.com" <email@hidden>
To: AppleScript <email@hidden>
Here's a quick script that puts the current date on the clipboard -
And
manipulates some of the text.
right now it looks like:
Friday- December 20- 2002 5-54-00 PM
... But I would really like it to look like:
12-20-02 5-54-00 PM ( short version - PC friendly)
... Basically what I'm working very quickly - I like to use the above
date
and time as a temporary file name.
Currently there are errors when using "/ or :" etc. - and also I
don't
want to use these because they are unfriendly in the PC environment...
any help would be appreciated.
--- the script ---
set the message_text to ((the current date) as string)
set the message_text to replace_chars(message_text, ",", "-")
set the message_text to replace_chars(message_text, ":", "-")
on replace_chars(this_text, search_string, replacement_string)
set AppleScript's text item delimiters to the search_string
set the item_list to every text item of this_text
set AppleScript's text item delimiters to the replacement_string
set this_text to the item_list as string
set AppleScript's text item delimiters to ""
return this_text
end replace_chars
set the clipboard to message_text
If you're using OS X you can get the date/time as a string in your
preferred format like this:
set dtString to do shell script "date '+%m-%d-%y %I-%M-%S %p'"
Marc K. Myers <email@hidden>
http://AppleScriptsToGo.com
4020 W.220th St.
Fairview Park, OH 44126
(440) 331-1074
[12/20/02 11:54:57 PM]
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.