Subject: | |
From: | |
Reply To: | |
Date: | Sat, 22 Jan 2011 15:16:58 -0500 |
Content-Type: | text/plain |
Parts/Attachments: |
|
|
On Jan 20, 2011, at 11:48 PM, Daniel A. Shockley wrote:
>> I recommend that, in spite of its apparent verbosity, you _always_ use
>>
>> AppleScript's text item delimiters
>>
>> JD
>
> I agree with John. I would also say this whole thing is a good
> candidate for a handler (function).
>
> Another thing: I'm a firm believer in restoring the AppleScript's text
> item delimiters to their previous state when I'm done with them:
>
>
> on removeExtension(somePath)
>
> set {oldDelims, AppleScript's text item delimiters} to {AppleScript's
> text item delimiters, "."}
> set pathWithoutExtension to (text items 1 through -2 of somePath) as string
> set AppleScript's text item delimiters to oldDelims
>
> return pathWithoutExtension
>
> end removeExtension
>
> Note also that one of the previous posters left off the "as string"
> (or "as text"), which would result in a list of the parsed strings -
> not what you want here.
Hey, suppose one of the folder names has a "." in it and the name doesn't?
Example
"After You:Users:Walter:Geek.Stuff:untitled....folder:Jay random rtf file"
To be safe one must break out the file name either by Finder or breaking the path down by ":" then applying the above method after checking to see if the file name has an extension, offset of "." in filename and then delete from the location of the point to the end point inclusive. Hmm better check that the resulting file name is non zero.
Experimentally "J" and "J." are legitimately different legitimate file names.
|
|
|