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]
**********************
|