Re: Getting file suffix
Re: Getting file suffix
- Subject: Re: Getting file suffix
- From: "Mark J. Reed" <email@hidden>
- Date: Mon, 13 Sep 2010 09:42:32 -0400
On Mon, Sep 13, 2010 at 8:27 AM, LuKreme <email@hidden> wrote:
>> Is this_item a path, or is it an alias?
>
> the display dialog line
>
> display dialog "the_item: " & this_item
>
> returns "Cerebus:Users:kreme:Downloads:image.png" so I'm guessing it's an alias. the line that sets it is:
No need to guess. display dialog (class of this_item)
You can't do string manipulation on an alias or a file object; you
have to ask for its name and operate on that.
> set item_suffix to getSuffix(this_item as text)
You have to be careful with that, since (this_item as text) is the
full pathname. If you ask for the suffix of
"Applications:MyApp.app:Contents:MacOS:MyApp", you'll get
"app:Contents:MacOS:MyApp".
(Message continues below)
> On 13-Sep-2010, at 05:38, André Renault wrote:
>
>> You should ask the Finder for the file suffix.
>
> Oh? How?
André told you how in the very next line of his message:
tell app "Finder" to get the name extension of thisFile
But as Luther pointed out, the Finder is somewhat picky about what it
considers a "name extension"; any old string of characters after a
period doesn't quite cut it.
So to sum up: if your extensions are sufficiently Finder-friendly, you
can just ask the Finder for them. If not, be sure to de-pathify the
string first (split on colons or ask the Finder for an alias's "name")
before looking for the period, and be sure to handle the case where
there isn't one.
--
Mark J. Reed <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