ExtendScript of the Week: Close All Files in a Book without Saving



Continuing with the series ‘Extendscript of the week’, we are providing an extendscript to Close All Files in a Book without Saving. This will show how to use FrameMaker ESTK to traverse a hierarchical book and perform operations on its components.

Download the zip file from CloseAllFilesInBookScript and unzip the content to local disk.

About the Script

  • It contains 3 scripts, CloseAllFilesInBook.jsx which is the caller function to handle the complete workflow, BookIterator.jsx which is used to iterate over the book components and BookCloseAllUtils.jsx that has utility functions used in the automation
  • The script works on all file types (FM/MIF/XML/Ditamap), nested books and its components as well as on the hierarchical components (Folders templates). Parameters have been defined in the main function according to which the components types will be acted upon (to process or leave unprocessed) making it a configurable setting.
  • The script traverses through all the open files in the book and closes it without prompting the user for Save dialog.  By default no file is saved.

Steps to use the Script?

  • Launch FrameMaker
  • Open any book (or use the file Sample.book from the samples provided here: CloseAllFilesInBookSampleFiles)
  • With focus on book, run the script CloseAllFilesInBook.jsx. This will create a new menu item in Book Menu
  • Goto File->Utilities->Close All Files in Book Without Saving
  • All open book files will now be closed without any prompt

This script will help reduce the painful task on clicking on the dialog each time on closing multiple files. It can be easily modified to Save all the files by default.


Anchal Arora

FrameMaker Engineering Team

(Resources: CloseAllFilesInBookScriptCloseAllFilesInBookSampleFiles)


Posted on 11-16-2011


  • By James - 11:23 PM on September 29, 2016   Reply

    That worked well. However, when I close FrameMaker the option ‘Close All Files in Book Without Saving’ in File > Utilities disappears the next time I open the book file. Is there a way to apply it permanently to the book, or must I run the script each time I open the book?

    • By Bharat Prakash - 2:27 PM on October 3, 2016   Reply

      Hi James ,

      Glad that the script worked for you. If you want the option to be present permanently , kindly place all the .jsx files in the “startup” folder inside FrameMaker install location . This will fire up the script everytime FM is opened.

      Please let us know if this works .

      Bharat Prakash

  • By James - 10:57 PM on September 28, 2016   Reply

    Hi Anchal Arora,

    I know it’s been a while since you wrote this post but I would find this script useful. I tried it out but it did not work, possibly because I am using FM 12 and not the version you used in 2011. When I run the script, I get the message “app.GetNamedMenu is not a function” – same message for a couple lines of text in the script.

    If you get this message, I would like to ask if you could create the script again or help me to get this working.


    • By Bharat Prakash - 12:09 PM on September 29, 2016   Reply

      Hi James,

      Thanks for the input.
      Before executing the step “With focus on book, run the script CloseAllFilesInBook.jsx. This will create a new menu item in Book Menu”, please select “Adobe FrameMaker 12 (12.0)” from the dropdown (default value is “ExtendScript Toolkit CS5”) in the ExtendScript interface.

      This should resolve the issue.

      Bharat Prakash

      • By Manohar - 10:39 AM on March 2, 2017   Reply


        Can we use any script to save all the files in a book? Other than using Shift+File command to save the files

        • By Stefan Gentz - 12:04 PM on March 2, 2017   Reply

          In FrameMaker 2017 Esc+f+S also works to save all open files.

Reply to Bharat Prakash