• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Automate the process of saving Framemaker documents (*.fm) as Xml Files

New Here ,
Apr 17, 2015 Apr 17, 2015

Copy link to clipboard

Copied

Hi,

I am new to framemaker. We have a list of Framemaker document files (*.fm files) coming  into a folder.  We need to pick up these files and convert to xml format (same as the saveAs opertion from the File menu).

I have written the follwing function to Save fm files to xml

Code to Save fm files to xml files

function saveAsXml (doc) {

   // Get required parameters for the save function.

    var params = GetSaveDefaultParams();

    var returnParamsp = new PropVals();

  

    // Replace the .fm extension with .mif.

    var saveName = doc.Name.replace (/\.[^\.\\]+$/,".xml");

  

    var i = GetPropIndex(params, Constants.FS_FileType);

    params.propVal.ival = Constants.FV_SaveFmtXml;

    // Save the document as XML.

    doc.Save(saveName, params, returnParamsp);

}

How to automate this process so that code checks -

1) New fm files in the folder

2) Saves the fm file as xml

3) Moves the saved fm file to a different folder

Thanks,

GC

[Message moved to Scripting Forum by moderator]

TOPICS
Scripting

Views

1.4K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 20, 2015 Apr 20, 2015

Copy link to clipboard

Copied

Have a look at the sample script below. The "while" loop waits for the specified number of milliseconds, then reads the contents of a directory and processes every individual file in the directory. In my example, it just prints the file path to the console. You would replace this part with your Open / Save as / Move sequence.

For more file system commands, refer to Adobe's Javascript Tools Guide, "File object functions".

var stop = false;

while( stop==false ) {

    // Wait for 20.000 ms

    $.sleep(20000);

    var fld = new Folder("c:/incoming");

    var filesInFld = fld.getFiles("*.fm");

    for(var f=0; f < filesInFld.length; f++) {

        // process the individual file

        $.writeln(filesInFld);

    }

    // Exit the  loop after 19:00

    var time = new Date();

    if( time.getHours() > 19 ) stop = true;

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 20, 2015 Apr 20, 2015

Copy link to clipboard

Copied

LATEST

JoH's script is good but it may eventually time out or run out of memory. Where are the .fm files coming from? A better approach may be to have a script on their machine that will automatically save and send an XML file to the incoming folder whenever they close the .fm document.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines