Re: Getting filename without extension...
Re: Getting filename without extension...
- Subject: Re: Getting filename without extension...
- From: Michelle Steiner <email@hidden>
- Date: Wed, 4 May 2005 18:15:53 -0700
On May 4, 2005, at 4:13 PM, David Crowe wrote: This can probably be optimized, but this should do the trick reasonably efficiently. I'm sure someone can figure out how to do it in one line of code.
set x to "abc.def.ghi" set AppleScript's text item delimiters to "." set y to every text item of x set z to first item of y if (count y) < 3 then return (z)
repeat with i from 2 to (count y) - 1 set z to z & "." & item i of y end repeat return(z)
How about this:
set x to "abc.def.ghi" set AppleScript's text item delimiters to "." set y to every text item of x if (count of y ) is less than 3 then return first text item of y else return reverse of (text items 2 through -1 of reverse of y) as text end if
but I think that my original method is best. Note that this should even work in OS9.
But it's not needed with OS9 because there is no such thing as file extensions in that OS. With things like this you have watch for special cases. The first return statement avoids problems when the list generated from the string has only one or two items in it.
-- "I'll see that when I believe it"
|
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden