0
votes

i'm trying to make applescript search for a file inside an application and then open it. The problem is that i want the file to open from anywhere in the mac eg. Desktop, library, downloads etc. No matter where it is.

This script works but the file has to be on the desktop only, it won't work anywhere else as the path is for the desktop

set theFile to ({path to desktop} as text) & "MagroXELA.app:Contents:Troll.mp3" tell application "Finder" to open file theFile

Kind regards, Alex

1
You need to explain more what the variables are. Are you wanting a script that will open "Troll.mp3" no matte where it is located? that, actually is rather complicated? is it always inside a magroXELA.app bundle? Will magroXELA always be running when the script runs? if so, you can use it's container reliably.jweaks
@jweaks, thanks for the comment. The mp3 file is always inside the MagroXELA application. This application is the actual script, but saved as an app, meaning the script is running. I just don't know the actual code to use as i'm still new to applescript. Thanksuser4060984
ah, then you can use "path to me". See my posted answer.jweaks

1 Answers

0
votes

There is an applescript line that returns the path of the process that is running the script, which works out to the physical location of a script file itself.

set appLocation to path to me as string
set theFile to appLocation & "Contents:Troll.mp3"
tell application "Finder" to open file theFile