Re: Simple newbie question
Re: Simple newbie question
- Subject: Re: Simple newbie question
- From: Emmanuel LEVY <email@hidden>
- Date: Thu, 18 Jun 2009 20:02:29 +0200
It's difficult to make a short code which would handle file names both
with and without extensions.
My shortest code (which works only if there is an extension, like
Michelle's proposition) is:
tell (info for MyFile) to return text 1 thru -(2 + (name extension's
length)) of its name
This is probably much faster than sending commands to Finder.
Emmanuel
On Jun 18, 2009, at 7:13 PM, Michelle Steiner wrote:
On Jun 18, 2009, at 9:50 AM, CYB wrote:
As you can see there are many ways to solve a task, in my opinion
is more easy this one
tell application "Finder"
set MyFile to alias "Lipstick:Users:g5:Desktop:HelveticaNeu.zip"
set oldTID to AppleScript's text item delimiters
set AppleScript's text item delimiters to {"."}
set NameNoExtension to text item 1 of (get name of MyFile)
set AppleScript's text item delimiters to oldTID
end tell
The problem with that is that a file's name may have more than one
period in it. So instead of "text item 1 of ...", use "(text items
1 through -2 of ...) as text"
-- Michelle
--
Velveeta is to American cheese as American cheese is to cheese.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (applescript-
email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden