MACSCRPT Archives

January 2011

MACSCRPT@LISTSERV.DARTMOUTH.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Claudio Braga <[log in to unmask]>
Reply To:
Macintosh Scripting Systems <[log in to unmask]>
Date:
Thu, 20 Jan 2011 15:18:02 +0100
Content-Type:
text/plain
Parts/Attachments:
text/plain (35 lines)
Il giorno 20/gen/2011, alle ore 15.12, Mark J. Reed ha scritto:

> On Thu, Jan 20, 2011 at 4:30 AM, Claudio Braga <[log in to unmask]> wrote:
>> removing the extension of the filename, any tricks to do this in the best way? Given that there are no out-of-the-box commands for this, do I just have to play with strings, looking for a . from the right etc.? looks a bit 'unprofessional'....
> 
> Well, if you need the extension, you can get it this way:
> 
> name extension of (info for someFile)
> 
> but if you want the filename with the extension removed, you're pretty
> much stuck with string manipulation.  (Or else tricks where you tell
> the Finder  not to include extensions and then ask it for the name,
> but that's slow and hacky.)
> 
> You may find it less "unprofessional" to use the value of the name
> extension to guide the manipulation, instead of using text item
> delimiters or similar.  For example:
> 
> tell (info for someFile)
>    set {theName, theExtension} to {name, name extension}
> end
> set bareName to text 1 through -(length of theExtension + 2) of theName

Yes , I like this solution, it looks much more elegant to me than checking backwards until the first . is found, trimming etc.

Thank you, I think I'll just use this

Regards

Claudio Braga
**********************
Brescia - Cuneo
[log in to unmask]
**********************

ATOM RSS1 RSS2