Re: Can't re-name file with time stamp
Re: Can't re-name file with time stamp
- Subject: Re: Can't re-name file with time stamp
- From: John W Baxter <email@hidden>
- Date: Wed, 20 Feb 2002 23:41:43 -0800
At 16:14 -0500 2/20/2002, Graham Fielder wrote:
>
The time dialog is displayed correctly but I get an error message saying :-
>
>
"Can't set name of "TEST " to "Time 21:04:20.".
>
>
What am I doing wrong?. (Using OS 9.2.2/AS 1.7)
There are 256 possible values in an 8 bit character (and 'a few more' in
Unicode).
The one out of those 256 which cannot be used in a file name on the Mac is
the : since it is the separator in paths.
You could move to a culture which writes time something like 21.04.20.
Or you could arrange to change the colons before using the date string
result. AppleScript's TIDs would be one way among many.
set oldTID to AppleScript's text item delimiters
set AppleScript's text item delimiters to {":"}
set temp to text items of time string of (current date)
set AppleScript's text item delimiters to {"-"}
set theName to "Time " & temp
set AppleScript's text item delimiters to oldTID
--theName contained (a few minutes ago) "Time 23-28-10"
The first two lines can be combined into
set {oldTID, AppleScript's text item delimiters} to {AppleScript's text
item delimiters, {":"}}
if you really want to. I usually don't want to (I'm more likely to use set
{a, b} to {b, a} to swap a's and b's values). And I'm letting the & in the
set theName... line coerce the list of three numbers into a string for
me...a bit unclear initially...it can be made explicit.
--John
--
John Baxter email@hidden Port Ludlow, WA, USA
_______________________________________________
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.