Re: What is the best way to get the name (without the extension) of a file?
Re: What is the best way to get the name (without the extension) of a file?
- Subject: Re: What is the best way to get the name (without the extension) of a file?
- From: Nigel Garvey <email@hidden>
- Date: Wed, 4 May 2005 21:16:55 +0100
Michelle Steiner wrote on Wed, 4 May 2005 08:26:15 -0700:
>On May 4, 2005, at 8:03 AM, Mark J. Reed wrote:
>
>> My first instinct would be to use string manipulation on the
>> filename - convert it to text, set the TID to '.', and if the
>> resulting list has more than one item, discard the last one.
>Using text item delimiters, I came up with this:
>
>set foo to choose file
>tell application "Finder"
> set the_name to the name of foo
> if the name extension of foo is "" then
> set i to -1
> else
> set AppleScript's text item delimiters to {"."}
> set i to -2
> end if
> set name_items to text items 1 through i of the_name
> set the_name to name_items as text
> set AppleScript's text item delimiters to ""
>end tell
>the_name
There's also this TID-less approach:
set foo to (choose file)
set {name:the_name, name extension:the_extension} to (info for foo)
if the_extension is not in {missing value, ""} then
set the_name to text 1 thru (-2 - (count the_extension)) of the_name
end if
the_name
NG
PS. Mark's reply wasn't included in the digest, though I see it's there
in the Web archive.
_______________________________________________
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