• 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: Getting the name of a file from an "alias"
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting the name of a file from an "alias"


  • Subject: Re: Getting the name of a file from an "alias"
  • From: Devon and Cornwall <email@hidden>
  • Date: Mon, 11 Jun 2001 18:07:05 -0700

At 11:15 PM +0200 6/11/01, Jan Pieter Kunst wrote:
>Greetings,
>
>I'm sure this must be extremely simple, but I can't find the answer.
>
>Let's say I have an variable x in my script that is set to an "alias". So,
>the value of x is:
>
>alias "Disk:folder1:folder2:file"
>
>How do I get just the name of the file (in the above case "file") into a
>string?

You could ask the Finder.

set Good to choose file
tell application "Finder" to name of Good

or have at it with TIDs. This example returns a parent path to a file. You can probably divine how to extract a file name by looking at it.

set c to choose file
extractParentPath(c)

on extractParentPath(f)
set {oldTID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, ":"}
if (f as string)'s last text item is "" then --its a folder (null string follows last colon)
try
set ItmsparentPath to "" & text items 1 thru -3 of (f as string) & ":"
on error --its a disk
set ItmsparentPath to f as string
end try
else --its a file
set ItmsparentPath to "" & text items 1 thru -2 of (f as string) & ":"
end if
set AppleScript's text item delimiters to oldTID
return ItmsparentPath
end extractParentPath

Devon


References: 
 >Getting the name of a file from an "alias" (From: Jan Pieter Kunst <email@hidden>)

  • Prev by Date: Re: Getting the name of a file from an "alias"
  • Next by Date: Re: moving pages in Quark
  • Previous by thread: Error geetting offset of char in errMsg
  • Next by thread: Re: Getting the name of a file from an "alias"
  • Index(es):
    • Date
    • Thread