Is there a CD Command to Go Down one Directory to Access the Resources Folder of an App

Using AppeScript, I have a MP3 file opening within the app I've created.


I need this to run, by placing it within the Resorces directory of the App itself.

Elsewise, the user will always be required to place that file in the 'Music' directory.


Here is what I use:

do shell script "afplay " & "/Users/Me/Music/dh3.mp3"


Here is the command that I try to use to go back one directory from Scripts, to access the MP3 file in Resources. It will not access it.

do shell script "afplay " & "cd ../dh3.mp3"


What is the change directory ( cd .. ) command to access the file? It would access the file by going down on directory from Scripts to Resources.

Accepted Reply

Thank you!

With the script you provided, I google'ed this: path to resource applescript

This is what I was able to compile:

set myPath to POSIX path of (path to resource "dh3.mp3" in directory "Stuff")
do shell script "afplay " & quoted form of myPath

It now works, as desired.

Replies

There are standard built-in ways to do this, such as Standard Additions' path to resource command:


  set filePath to POSIX path of (path to resource "dh3.mp3")


or if using AppleScriptObjC, various URLForResource... / pathForResource... methods from the NSBundle class:


  set filePath to (current application's NSBundle's mainBundle's pathForResource:"dh3" ofType:"mp3") as text

Thank you!

With the script you provided, I google'ed this: path to resource applescript

This is what I was able to compile:

set myPath to POSIX path of (path to resource "dh3.mp3" in directory "Stuff")
do shell script "afplay " & quoted form of myPath

It now works, as desired.