2
votes

I'm making a small script that needs to use the name of the parent directory of the script itself (.scpt file) a variable.

For example, the script is located at /Users/spongebob/MyProject/myscript.scpt

I need to set the variable called myprojectdir to MyProject.

I've tried

set myprojectdir to parent of POSIX path of me

and other variations of this based on search results but I always end up with an error

Can’t get POSIX path.

Where am I going wrong? Thanks

1

1 Answers

3
votes

AppleScript itself has no idea.

You have to ask System Events

tell application "System Events" to set myprojectdir to name of container of (path to me)

or the Finder

tell application "Finder" to set myprojectdir to name of parent of (path to me)