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: Emile Schwarz <email@hidden>
- Date: Thu, 05 May 2005 08:49:41 +0200
Hi,
this is just a question of good sense. I saw that "AppleScript's text item
delimiters" was changed in the code, but nobody tells that it is a good idea to
get its value prior the change and restore it after you do not need the change.
Doing so is good for other people health (our users for example).
HTH,
Emile
PS:
Macromind Director long time ago was changing the number of colors (back to 256
from n millions for example) when launched, but do not set the number of colors
back on exit :( Weird way of developping a software.
Number of colors: 256 colors = 8 bits; n millions of colors: 24 bits (or 32 bits).
email@hidden wrote:
From: Nigel Garvey <email@hidden>
Subject: Re: What is the best way to get the name (without the extension) of a file?
To: "AppleScript Users" <email@hidden>
Message-ID: <email@hidden>
Content-Type: text/plain; charset="US-ASCII"
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