Reputation: 8918
Playing with AppleScript I am confused on what I am doing wrong when I try to call another AppleScript from the Scripts
folder. My current script is saved as foo.app
and I see the structure from the Bundle Contents
but when I try to call bar.app
from inside the Scripts
folder I get a dialog of Resource not found
.
After referencing "How to access from AppleScript a bundled file within a Cocoa-AppleScript Application?" I tried:
tell application "Finder"
set thisFolder to (container of (path to me)) as string
set insideApp to thisFolder & (path to resource "bar.app")
end tell
When that produced the error I did some more searching I referenced "How do I get the Scripts folder in the application bundle?" and tried:
tell application "Finder"
set thisFolder to (container of (path to me)) as string
set insideApp to (thisFolder as alias) & (path to resource "bar.app" in directory "Scripts")
end tell
Targeting description.rtfd
I display the variable thisFolder
and the dialog I get Macintosh HD:Users:darth_vader:Desktop:
but it produces Resource not found
when I run:
tell application "Finder"
set thisFolder to (container of (path to me)) as string
display dialog thisFolder
set insideApp to thisFolder & (path to resource "Contents:Resources:description.rtfd")
end tell
What exactly am I doing wrong and how do I call from within the Scripts
folder?
Upvotes: 0
Views: 951
Reputation: 285064
There is a general misunderstanding:
path to me
points to the path to the script (bundle).
container of (path to me)
points to the path to the enclosing folder of the script (bundle)
So it's:
set insideApp to path to resource "bar.app"
or:
set insideApp to path to resource "bar.app" in directory "Scripts"
or (preferable)
set insideApp to alias ((path to me as text) & "Contents:Resources:description.rtfd")
The Finder
is not needed at all.
Upvotes: 1