• 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: What is the best way to get the name (without the extension) of a file?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: What is the best way to get the name (without the extension) of a file?


  • Subject: Re: What is the best way to get the name (without the extension) of a file?
  • From: kai <email@hidden>
  • Date: Fri, 6 May 2005 17:09:58 +0100


On Friday, May 6, 2005, at 10:37 am, Nathan Day wrote:

how about

set fileName to "com.apple.iTunes.eq.plist"
if (offset of "." in fileName) > 0 then
   set {theOldDelimieter, text item delimiters} to {text item delimiters, "."}
   set fileName to (text items 1 thru -2 of fileName) as string
   set text item delimiters to theOldDelimieter
end if
fileName

You could squeeze more speed from this approach with a little tweaking. This, for example, is about 7 times faster here:


set fileName to "com.apple.iTunes.eq.plist"
considering case
	if "." is in fileName then
		set d to text item delimiters
		set text item delimiters to "."
		set fileName to fileName's text 1 thru text item -2
		set text item delimiters to d
	end if
end considering
fileName

---
kai

_______________________________________________
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


References: 
 >Re: What is the best way to get the name (without the extension) of a file? (From: Nathan Day <email@hidden>)

  • Prev by Date: Re: Nice Automator article on O'Reilly
  • Next by Date: Re: Script as internet helper protocol in tiger
  • Previous by thread: Re: What is the best way to get the name (without the extension) of a file?
  • Next by thread: Choose file of type with Panther
  • Index(es):
    • Date
    • Thread