• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
RE: remove suffix
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: remove suffix


  • Subject: RE: remove suffix
  • From: Nigel Garvey <email@hidden>
  • Date: Fri, 28 Sep 2001 12:22:35 +0100

"Zavatone, Alex" wrote on Thu, 27 Sep 2001 15:49:49 -0700:

>you could adopt an approach I use in Director's Lingo.
>
>If you set the itemdelimiter or text delimiter to a "." then you can just
>return item, "the number of items in mystring - 1) of your text string and
>that will be what you want.

1) That should be "the number of *text items* in mystring -1".
2) If there's more than one dot in mystring, that particular text item
will only consist of the text from between the last two.

Marc has suggested:

> set aString to (text items 1 thru -2 of aString) as text

This is more versatile than my "word" suggestion, though it could be more
economically phrased in the same manner:

set aString to text 1 thru text item -2 of aString

All of the suggestions so far assume that the file name actually *has* a
suffix, but in the context of the original enquiry, that's probably OK.
However, how about this?

on stripFileSuffix from aString
set AppleScript's text item delimiters to {":"}
if text item -1 of aString contains "." then
set AppleScript's text item delimiters to {"."}
set aString to text 1 thru text item -2 of aString
end if
set AppleScript's text item delimiters to {""}
return aString
end stripFileSuffix

stripFileSuffix from "My disk:my folder.suffix:my file.suffix"

NG


  • Prev by Date: Re: Screenshot of Window (using Akua Sweets)
  • Next by Date: Re: How to tell if a file is busy?
  • Previous by thread: Re: remove suffix
  • Next by thread: RE: remove suffix
  • Index(es):
    • Date
    • Thread