Copy link to clipboard
Copied
Copy link to clipboard
Copied
// bookOfSelectedFolder.jsx
//DESCRIPTION: Create a book and add indd-files of a choosen folder
var myFolder = Folder.selectDialog( "Choose a folder" );
if( myFolder != null ){
// get indd-files of choosen folder
var myFiles=myFolder.getFiles( "*.indd" );
if ( myFiles.length > 0 ){
var myBookFileName = myFolder + "/"+ myFolder.name + ".indb";
myBookFile = new File( myBookFileName );
try{
//does the book file exist?
myBook=app.open( myBookFile );
}
catch ( e ){
//the book file doesn't exist, so make a new one
myBook=app.books.add( myBookFile );
myBook.automaticPagination=false;
for ( i=0; i < myFiles.length; i++ ){
myBook.bookContents.add( myFiles );
}
myBook.save( );
}
}
}
Copy link to clipboard
Copied
Hi.
This script was fantastic through CS3, but now in CS4, it crashes the application. When I use the debugger in the ESTK, it crashes around this line:
myBook=app.open( myBookFile );
Does anyone know what the difference is in CS3 and 4 that is causing the error? I'm still learning how to script and have not been able to figure it out myself.
Thanks in advance.
Copy link to clipboard
Copied
Here's my version of the script — now works in CS4 — may be it would come in handy to somebody:
var myFolder = Folder.selectDialog( "Select a folder with InDesign files" );
if ( myFolder != null ) {
var myFiles = [];
var myAllFilesList = myFolder.getFiles();
for (var f = 0; f < myAllFilesList.length; f++) {
var myFile = myAllFilesList;
if (myFile instanceof File && myFile.name.match(/\.indd$/i)) {
myFiles.push(myFile);
}
}
if ( myFiles.length > 0 ) {
var myBookFileName = myFolder + "/"+ myFolder.name + ".indb";
myBookFile = new File( myBookFileName );
if ( myBookFile.exists ) {
if ( app.books.item(myFolder.displayName + ".indb") == null ) {
myBook = app.open( myBookFile );
}
}
else {
myBook = app.books.add( myBookFile );
myBook.automaticPagination = false;
for ( i=0; i < myFiles.length; i++ ) {
myBook.bookContents.add( myFiles );
}
myBook.save( );
}
}
}
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Find more inspiration, events, and resources on the new Adobe Community
Explore Now