You can do something like the code below, which finds a settings file with the same name as the script, but with a .cfg extension.
// Make a File object for the settings XML file. var settingsFile = new File($.fileName.replace (/\.jsx$/i , ".cfg")); if (settingsFile.exists === false) { $.writeln ("Settings file does not exist: " + settingsFile.fsName); }
The $.fileName property gives you the path to the currently running script. Here I am replacing the .jsx extension with .cfg.
In your case, you could use something like this:
// Make a File object for the template. var template = new File($.fileName.replace (/[^\/]+$/, "changes-template.fm")); if (template.exists === false) { $.writeln ("Template does not exist: " + template.fsName); }
One important thing: make sure you save the script before using this code. $.fileName returns (Script#) from an untitled script.
-Rick