• 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: Michelle Steiner <email@hidden>
  • Date: Wed, 4 May 2005 08:26:15 -0700


On May 4, 2005, at 8:03 AM, Mark J. Reed wrote:

My first instinct would be to use string manipulation on the filename  -  convert it to text, set the TID to '.', and if the resulting list has more than one item, discard the last one.  I am not saying it's better, mind.  It's just that temporarily changing something just for a side effect is something I try to avoid; never know what might be going on at the same time the script is running that might get confused by the sudden change in the value of the extension hidden flag.

I considered that, but decided that the chances of it happening were low enough to make the risk negligible.


Using text item delimiters, I came up with this:


set foo to choose file
tell application "Finder"
    set the_name to the name of foo
    if the name extension of foo is "" then
        set i to -1
    else
        set AppleScript's text item delimiters to {"."}
        set i to -2
    end if
    set name_items to text items 1 through i of the_name
    set the_name to name_items as text
    set AppleScript's text item delimiters to ""
end tell
the_name


-- Michelle


-- 

Don't dream it.  Be it.  --RHPS


 _______________________________________________
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: What is the best way to get the name (without the extension) of a file?
      • From: "Shane Stanley" <email@hidden>
References: 
 >What is the best way to get the name (without the extension) of a file? (From: Michelle Steiner <email@hidden>)
 >Re: What is the best way to get the name (without the extension) of a file? (From: "Mark J. Reed" <email@hidden>)

  • Prev by Date: Re: New Tiger dictionary format example posted
  • Next by Date: Choose file of type with Panther
  • Previous by thread: Re: What is the best way to get the name (without the extension) of a file?
  • Next by thread: Re: What is the best way to get the name (without the extension) of a file?
  • Index(es):
    • Date
    • Thread