Get AppleScript Path of Parent Folder

applescriptfolderspath

I am writing an AppleScript that will be run from a USB drive, but the dive name may change often so I need to figure out how to get the directory path of the parent folder that contains the script.

This gets me the entire directory with directory to the file, I need the directory of its parent folder:

set pPath to path to me as text
display dialog pPath

I came across this (which is what I need), but I need an AppleScript path, not a POSIX path!

set pPath to POSIX path of ((path to me as text) & "::")
display dialog pPath

When the script is run it should detect the directory path to the script, the first example of code does this, but it then needs to go up one folder to the parent folder which contains the script (the second example does this) but I need it converted from the POSIX path to Applescript path that uses ":" instead of "/".

Best Answer

AppleScript is written in English. Read what it says! Remove the posix path of from the code, and you'll get the HFS path.

Full code:

tell application "Finder" to get (container of (path to me)) as text