• 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: [Q] How to get a containing folder of a given file?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Q] How to get a containing folder of a given file?


  • Subject: Re: [Q] How to get a containing folder of a given file?
  • From: JongAm Park <email@hidden>
  • Date: Sat, 23 Sep 2006 00:00:59 -0700

Hello, David.

These are what I figured out.

1. There seems to be stack corruption or heap problem of the Script Editor.
   After relaunching of the ScriptEditor, it started working.

2. How to retrieve the containing folder is :

tell application "Finder"
set my_file_path to path to desktop folder
-- alias "Macintosh HD:Users:jongampark:Desktop:"
set directory_path to (container of my_file_path)
-- folder "jongampark" of folder "Users" of startup disk of application "Finder"


   -- class of directory_path
   -- folder


POSIX path of (directory_path as alias) -- "/Users/jongampark/" end tell


container returns a folder.
You can't use "POSIX path of " with the folder type. The AppleScript doesn't support converting folder to POSIX path. However you can convert the folder to an alias, and the alias can be converted to POSIX path.


You can find out it more by looking up O'Reilly -- AppleScript: The Definitive Guide, 2nd Edition <http://safari.oreilly.com/0596102119/applescpttdg2-CHP-14-SECT-5#X2ludGVybmFsX1RvYz94bWxpZD0wNTk2MTAyMTE5L2FwcGxlc2NwdHRkZzItQ0hQLTEy>.

Thanks.


david wrote:
we are using the same AS version:
AppleScript version 1.10.7
script editor version 2.1.1
standard additions 1.10.7

i am running Mac OS X 10.4.6 -- are we using the same OS X version
i copied the script you created, so we are using the same syntax

i can't think of any other reason there is a difference

let me know what you find!

David in Maine

On Sep 20, 2006, at 9:16 AM, JongAm Park wrote:

Hello.

It is interesting. Actually one of my friend also tested the code, and it worked on his machine.
However it doesn't work for me.


AppleScript version is 1.10.7

Is it different?



_______________________________________________ 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: 
 >[Q] How to get a containing folder of a given file? (From: JongAm Park <email@hidden>)
 >Re: [Q] How to get a containing folder of a given file? (From: david <email@hidden>)
 >Re: [Q] How to get a containing folder of a given file? (From: david <email@hidden>)
 >Re: [Q] How to get a containing folder of a given file? (From: JongAm Park <email@hidden>)
 >Re: [Q] How to get a containing folder of a given file? (From: david <email@hidden>)
 >Re: [Q] How to get a containing folder of a given file? (From: JongAm Park <email@hidden>)
 >Re: [Q] How to get a containing folder of a given file? (From: david <email@hidden>)

  • Prev by Date: Re: AppleScript runs slow on Intel Macs
  • Next by Date: Re: AppleScript runs slow on Intel Macs
  • Previous by thread: Re: [Q] How to get a containing folder of a given file?
  • Next by thread: Re: [Q] How to get a containing folder of a given file?
  • Index(es):
    • Date
    • Thread