i’m migrating an old Indesign script i created to process book documents before starting to work on them.
i’m trying to get a list of all documents in the book and open each one, process and save it.
i created a UXP plugin, but when i’m trying to access the bookContent properties like the filePath i’m getting back rejected promisses and not valid objects
i already tried adding full file system permissions with no luck.
i tried
await book.bookContents.firstItem().filePath
but i’m getting back some kind of Symbol()
without await i get a resolved Promise which the result is an “n”…
I see this is older, but I have the same issue. Not sure if you ever worked it out.
this line is the issue:
// Open the .indd file
const filePath = bookContent.filePath;
I see it’s a promise, but it’s not resolving, and so I’ve tried to resolve it, and this is what I found.
Promise Error: Error: Could not find an entry of ‘file:///Users/mlynch/Library/CloudStorage/GoogleDrive-me@here.com/.shortcut-targets-by-id/1IM2FTLoqXdBU1IuQ%20Adoption%20Source%20Files/_SP_20’
Hello Mike!
I’ll be brief, maybe you’ve already found a solution.
const bookDocuments = async (book) => {
let allPromisedFullNames = book.bookContents
.everyItem().getElements()
.map(e => e.fullName); // Array of Promises here
/*
let allPromisedFullNames = book.bookContents.everyItem().fullName; //This returns not an Array, but collection. Be careful!
*/
let fullNames = await Promise.all(allPromisedFullNames); // Now we have the Array of Files (not opened)
return fullNames;
};
/////// call function to handle every document in the book
let files = await bookDocuments(app.books.item(0)); //select a book by item, by name...
files.forEach(indd => {
let adoc = app.open(indd);
//... handle ...
adoc.close(SaveOptions.YES); //or without saving, if you want
});