Getting current script name

Is there a way to set a variable to the name of the current running script?

I wrote a script to backup files from our server, and from time to time, I modify the script, and change the version number of the script. At the end of the script, it generates a report that includes everything that it did. One thing that I want in that report is which version of the script is running. I change the name of the script in the Finder everytime I edit it. For example… Backup Script v1.03 becomes Backup Script v1.04. Right now, I manually change the version number in the script, but I’d really like the script to pickup it’s own name.

Thanks for any help

Is the script saved as an app or are you running it from Script Editor ??


This works if the script is run from the script menu or if it is saved as an application. You can change the name in Finder and the dialog will show the updated name.

set myName to name of (info for (path to me))

display dialog myName


EDIT: Just saw Mark’s post. I should have said that it won’t work when run from Script Editor - well, it does, but just displays “Script”

If you want it to do so from script editor, then make sure its the front most document.
and use

set script_version to name of document 1

Thanks, I was just looking up how to do that (although I think I should have been able to figure it out on my own.)


Wow… thanks for the fast reply… I am running it as an app. So that line should work perfectly.

Thanks again!