How do I access files contained in my AppleScript Studio application's main bundle?

Q: How do I access files contained in my AppleScript Studio application's main bundle?

A: If you have files in your AppleScript Studio application's bundle (that is, in your Resources folder under Groups & Files (see Figure 1), you can access them by using "resource path of main bundle" plus the pathname hierarchy to the file. See Listing 1 for an example.

Figure 1: Groups & Files showing pathname hierarchy.

Figure 1, Groups & Files showing pathname hierarchy.

Listing 1: Using 'resource path of main bundle'

set myFile to (resource path of main bundle) & "/path/to/your/file.txt"

When you run this, myfile would contain a path similar to "/Users/username/AppleScript Studio.app/Contents/Resources/path/to/your/file.txt". (This path would likely include ".../build/Debug" when testing within Xcode.)

For more information on bundles in AppleScript Studio, see the Application Suite > Terminology > bundle section of "AppleScript Studio Terminology Reference"; you can find it in the ADC Reference Library at Reference > AppleScript > Tools.

Document Revision History

DateNotes
2007-02-05Clarified pathname hierarchy references; added pointer to reference guide.
2006-10-09Explains how to access files stored within an AppleScript Studio application.

Posted: 2007-02-05


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.