Skip to main content
Participant
March 9, 2022
Answered

How to export chapter list from book in framemaker(Unstructured)

  • March 9, 2022
  • 2 replies
  • 728 views

I have a requirement to copy all the chapter list from a framemaker book to excel, as we are maintaining all chapters in a different folder also usig framemaker unstructured version, i am not getting any option copy the chapter list. can anyone help me with this.

    This topic has been closed for replies.
    Correct answer frameexpert

    Copy the code below to a text file and save it with a .jsx extension. Open your FrameMaker book, and choose File > Script > Run and select the script. It will create a text file in the same folder as the book that has a list of the file names.

     

    #target framemaker
    
    main ();
    
    function main () {
    
    	var book;
    	
    	book = app.ActiveBook;
    	if (book.ObjectValid () === 1) {
    		if (book.Name !== "") {
    			processBook (book);
    		}
    		else {
    			alert ("Please save the book and run the script again.",
    				"www.frameexpert.com");
    		}
    	}
    }
    
    function processBook (book) {
    	
    	var file, bookComp, compFile;
    	
    	// Make a text file in the same folder as the book.
    	// It will have the same name as the book but with a txt extension.
    	file = new File (book.Name.replace (/[^\.]+$/, "txt"));
    	file.open ("w");
    	
    	bookComp = book.FirstComponentInBook;
    	while (bookComp.ObjectValid () === 1) {
    		compFile = new File (bookComp.Name);
    		file.writeln (File.decode (compFile.name));
    		bookComp = bookComp.NextBookComponentInDFSOrder;
    	}
    	
    	file.close ();
    }
    

    2 replies

    frameexpert
    Community Expert
    frameexpertCommunity ExpertCorrect answer
    Community Expert
    March 9, 2022

    Copy the code below to a text file and save it with a .jsx extension. Open your FrameMaker book, and choose File > Script > Run and select the script. It will create a text file in the same folder as the book that has a list of the file names.

     

    #target framemaker
    
    main ();
    
    function main () {
    
    	var book;
    	
    	book = app.ActiveBook;
    	if (book.ObjectValid () === 1) {
    		if (book.Name !== "") {
    			processBook (book);
    		}
    		else {
    			alert ("Please save the book and run the script again.",
    				"www.frameexpert.com");
    		}
    	}
    }
    
    function processBook (book) {
    	
    	var file, bookComp, compFile;
    	
    	// Make a text file in the same folder as the book.
    	// It will have the same name as the book but with a txt extension.
    	file = new File (book.Name.replace (/[^\.]+$/, "txt"));
    	file.open ("w");
    	
    	bookComp = book.FirstComponentInBook;
    	while (bookComp.ObjectValid () === 1) {
    		compFile = new File (bookComp.Name);
    		file.writeln (File.decode (compFile.name));
    		bookComp = bookComp.NextBookComponentInDFSOrder;
    	}
    	
    	file.close ();
    }
    
    Lavanya94Author
    Participant
    March 9, 2022

    Woww... Its working absolutely thank you so much, it made my work so easy.

    K.Daube
    Community Expert
    Community Expert
    March 9, 2022

    Hello Radha,

    In cases like this I'm happy to have Snagit installed. I capture the image of anything and then it extrancts the text to the clipboard (at least 95% of the text is correct).

    You may send me such an image offline and get the text within the day... (unfortunately not a thing to be done every day).

    But you give me the idea to create a script for this (not ready today).

    Lavanya94Author
    Participant
    March 9, 2022

    Thank you so much for your kind response, I will be more happy if you provide me the script(In future), as image conversion is not 100% correct and it will not be the direct solution for this case, as of now i am converting book file to the .mif and opening with text editor and copying all the file names. Pls give me the better idea or script if you have further.

     

    Thank You.