• 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
Getting filename without extension...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Getting filename without extension...


  • Subject: Getting filename without extension...
  • From: David Crowe <email@hidden>
  • Date: Wed, 4 May 2005 17:13:13 -0600

Title: Getting filename without extension...
This can probably be optimized, but this should do the trick reasonably efficiently. I'm sure someone can figure out how to do it in one line of code.

set x to "abc.def.ghi"
set AppleScript's text item delimiters to "."
set y to every text item of x
set z to first item of y
if (count y) < 3 then return (z)

repeat with i from 2 to (count y) - 1
  
set z to z & "." & item i of y
end repeat
return(z)


Note that this should even work in OS9. With things like this you have watch for special cases. The first return statement avoids problems when the list generated from the string has only one or two items in it.

- David Crowe
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Getting filename without extension...
      • From: Malcolm Fitzgerald <email@hidden>
    • Re: Getting filename without extension...
      • From: Michelle Steiner <email@hidden>
  • Prev by Date: Re: Nice Automator article on O'Reilly
  • Next by Date: Re: Nice Automator article on O'Reilly
  • Previous by thread: Tiger breakage: get item of class record
  • Next by thread: Re: Getting filename without extension...
  • Index(es):
    • Date
    • Thread