script that detect the path where it is running from

Is there a way for a script to detect the location where it is running from ?

Try:

path to me

in your compiled Applescript.

Best wishes

John M

“path to me” gives you the path of where the script editor resides. I believe mrick wants the path to the location of his script.

Yes, that’s true, but only when you run the script in Script Editor. If you run the script elsewhere, such as the script menu, you’ll get a path to the actual script file.

display dialog (path to me as string)

Different script runners may handle this differently. When a script is saved as an application, it may report its path more reliably. If saving as app isn’t an option I suppose one could save as an .scptd (script bundle) and use something like

path to resource "Scripts"
display dialog result as string

to get something near the script file path.