So I have been trying to create an AppleScript application that when I click on it, it opens a mp3 file within the packages contents and resources. This is the only code I have within the script:

set filepath to (path to me as string) & "Contents:Resources:Jingle bells.mp3"

tell application "Finder"
    open alias filepath

but I receive a "script error" message saying: error "Finder got an error: Can’t get alias \"Macintosh HD:Users:bobby.hay:Desktop:Song.app:Contents:Resources:Scripts:main.scptContents:Resources:Jingle bells.mp3\"." number -1728

I am trying to get the application to open Jingle bells.mp3 which is inside /Contents/Resources of my script.

  • Welcome to Ask Different! :) Is the code you've included in your question the verbatim code you're using in your application? If so, the first thing that comes to mind is the name of your .mp3 file - I assume it's not file name.mp3? On the other hand, if that is your filename, can I ask you to edit your question to elaborate on what it's not working means? Do you get an error message? Something else?
    – Monomeeth
    Commented Aug 14, 2018 at 7:54

2 Answers 2


Assuming that by "open" you mean play the mp3, the following script should do exactly what you want:

set myFolder to POSIX path of (path to me)
set contentFile to myFolder & "Contents/Resources/Jingle bells.mp3"
do shell script "afplay " & quoted form of contentFile

Above, we set myFolder to the POSIX path of .app file that is being run. Then we set contentFile to the POSIX path of the .app file plus the location in the internal directory which links to the file you want to play (Contents/Resources/Jingle bells.mp3 in your case). Finally, we use the shell command afplay (man page here) to play your mp3 file.

Hope this helps!

Best, Tom

  • Thank you very much but, what goes inside the last set of quotes in the last line. (You have probably explained this and I just didn't understand, i'm sorry if this is the case)
    – John Smith
    Commented Aug 14, 2018 at 21:58
  • No worries! I hope that solved your question. As for the extra & " "; I have noticed that in the past, not adding an empty quote will cause the shell command not to work. However, I have just tried it without the extra addition and it seems to work either way so I'll remove it from my original answer to aid clarity for any future viewers. Best
    – Tom
    Commented Aug 14, 2018 at 22:03
  • With both of the codes with and with without the quotes I receive an error message saying "Unspecified exception" am I meant to have more code around what you have given me?
    – John Smith
    Commented Aug 14, 2018 at 22:44
  • The code I have provided you with above is stand-alone. As long as you have saved the script as a .app file and the song you want to play is located in /Contents/Resources and is called Jingle bells.mp3, then it should work perfectly. Are there any, more specific, error messages you receive?
    – Tom
    Commented Aug 14, 2018 at 23:04
  • Thank you very much, it just doesn't seem to work on my computer when I give it to another computer it works perfectly fine.
    – John Smith
    Commented Aug 14, 2018 at 23:46

Give this a try:

set filepath to path to resource "Jingle bells.mp3"

tell application "Finder"
    open filepath
end tell

path to resource is probably the most reliable method for finding your file.

Secondly, make sure that you are editing this script by dragging and dropping the "app" onto the Script Editor icon, not by navigating inside the bundle and opening main.scpt. This will ensure it has access to the bundle resources.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .