• 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: how do you tell what folder a file is in? - how to tell if a file exists part
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how do you tell what folder a file is in? - how to tell if a file exists part


  • Subject: Re: how do you tell what folder a file is in? - how to tell if a file exists part
  • From: JollyRoger <email@hidden>
  • Date: Sun, 28 Oct 2001 07:02:45 -0600

On 10/26/2001 1:27 PM, "Arthur Cormack" <email@hidden> wrote:

> on getParentFolder(whichOne) --which one is an alias to a file
> set oldDelims to AppleScript's text item delimiters
> set AppleScript's text item delimiters to {":"}
> set thisOne to the text items of (whichOne as text)
> set thisTextItemCount to count the (text items of thisOne)
> set thisFullPathToFolder to ((text items 1 thru (thisTextItemCount -
> 1) of thisOne) as text) --& ":"
> set AppleScript's text item delimiters to oldDelims
> return thisFullPathToFolder
> end getParentFolder

Hi Arthur,

The handler you posted doesn't work if you pass it a folder. Also, it
doesn't pass the entire path of the parent folder, only the name. :/

I've been using the following handler for ages. It does all of the above:

-- begin script
return ParentFromPath((path to the startup disk as text) & "Desktop
Folder:", true)
on ParentFromPath(thePath, wantPath)
set thePath to (thePath as text)
set saveDelim to AppleScript's text item delimiters
set AppleScript's text item delimiters to {":"}
set pathAsList to text items of thePath
if the last character of thePath is ":" then
set idx to (the number of text items in thePath) - 2
else
set idx to -2
end if
if wantPath then
set folderName to ((text items 1 through idx of pathAsList) as text)
& ":"
else
set folderName to item idx of pathAsList
end if
set AppleScript's text item delimiters to saveDelim
return folderName
end ParentFromPath
-- end script

HTH

JR


References: 
 >Re: how do you tell what folder a file is in? - how to tell if a file exists part (From: "Arthur Cormack" <email@hidden>)

  • Prev by Date: Re: Fetch script & dialog screen
  • Next by Date: Re: Set the time in 8.1 and 7.6 remotely?
  • Previous by thread: Re: how do you tell what folder a file is in?
  • Next by thread: Re: can't wait... and not(no-can-do)
  • Index(es):
    • Date
    • Thread