Choose a book, choose a datasource, iterate through the book checking documents for changes and updating the panel with the changes. You could then use Update Datasource on the EasyCatalog Pop Out Menu to write the changes back to the datasource.
To install this script, navigate to the Adobe InDesign Application Directory and paste the script file into the following folder ‘Scripts -> Scripts Panel’. The script can then be run from the Scripts panel; this is found in ‘Window -> Utilities -> Scripts’.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | #target InDesign var path = new File("Macintosh HD"); var myEasyCatalog = app.easycatalogObject; try { // INITIATE CHOOSE BOOK DIALOG var currentBook = chooseBook(); // INITIATE CHOOSE DATA SOURCE DIALOG var currentDS = chooseDataSource(); // INITIATE BOOK CYCLE cycleBook(currentBook, currentDS); } //CUSTOM ERROR CATCH catch (error) { alert("ERROR: " + error + "."); } function cycleBook(book, myDS) { //COUNT DOCUMENTS IN BOOK var bookLength = book.bookContents.count(); //CYCLE THROUGH DOCUMENTS for (var i = bookLength-1; i>=0; i--) { //OPEN DOCUMENTS var activeDoc = app.open(book.bookContents[i].fullName, true) //INITIATE UPDATE LINKS updateLinks(activeDoc); //ONCE CYCLE COMPLETE DISPLAY "COMPLETE!" AND CLOSE BOOK if (i === 0) { alert("Complete!"); book.close(); } } function updateLinks (document) { //SYNCHRONISE DOCUMENT TO CHECK FOR DIFFERENCES myDS.synchronizeDocument(document); //UPDATE SNAPSHOT myDS.updateSnapshot(document); document.close(); } } //--------------- DIALOG FUNCTIONS //CHOOSE BOOK DIALOG function chooseBook() { var openBook = path.openDlg("Please select an InDesign Book"); if (openBook != null) { var bookObject = app.open(File(openBook)); return bookObject; } else { //THROW ERROR throw "No InDesign Book selected"; } } //CHOOSE DATASOURCE DIALOG function chooseDataSource() { var labelWidth = 200; var minWidth = 156; var dsDialog = app.dialogs.add({name:"Data Source Selection"}); var myDropDown; with (dsDialog.dialogColumns.add()) { with (dialogRows.add()) { with (dialogColumns.add()) { with (dialogRows.add()) { staticTexts.add({staticLabel:"Please select a datasource to update:", minWidth:labelWidth}); //CREATING A LIST OF DATASOURCES AND ADDING THEM TO AN ARRAY var dsArray = app.easycatalogObject.datasources.everyItem().name; myDropDown = dropdowns.add(); myDropDown.stringList = dsArray; myDropDown.selectedIndex = 0; } } } } //SHOW DIALOG var dsResult = dsDialog.show(); //IF SELECTION HAS BEEN MADE WILL RETURN DATASOURCE TO EASYCATALOG if (dsResult) { myDS = app.easycatalogObject.datasources.item(myDropDown.selectedIndex); return myDS; } //THROW ERROR AND RETURN FALSE IF NO SELECTION HAS BEEN MADE throw "No datasource selected"; return false; } //--------------- DIALOG FUNCTIONS END |