Applescript - Unable to find resource when inside application I have a regular Applescript application bundle that executes an applescript file when it's run. I'm trying to run a shell file that is located at "/Contents/Resources/Data/df.sh", however with the code I'm using, it keeps giving me "resource not found" errors.

set bashFile to path to resource "df.sh"
do shell script "bash " &amp; bashFile


I'm really new to Applescript, so there's the chance I'm doing something obvious wrong.
There are a few reasons it didn't work.


path to resource basically takes the bundle path and finds files in there, so you need to actually put the subdirectory, in this case "Data."
Applescript uses its own (stupid) file path syntax, so you need the POSIX version.
It breaks on spaces because appending the POSIX path ~/Desktop/test folder shows up as 2 arguments to bash. To fix this just put quotes around it, as you would any other time, with quoted form of.


Here's the fixed script:


set bashFile to path to resource "Data/df.sh"
do shell script "bash " & quoted form of (POSIX path of bashFile)