Interpolate into an AppleScript called through Cmd

Build the script as a string, then pass that string to osascript.

script = """ set strPath to POSIX file "$default"
POSIX path of (choose file with prompt "Pick a file:" default location strPath)
"""
read(`osascript -e $script`, String)
3 Likes