Quantcast
Channel: Adobe Community: Message List - FrameMaker Scripting
Viewing all articles
Browse latest Browse all 3715

Re: Accessing file system

$
0
0

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


Viewing all articles
Browse latest Browse all 3715

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>