Copy link to clipboard
Copied
Hi all,
I have 185 idml files in different folders, all page size must be 6 mm smaller
this is what i have and works. Now I search for the code to open all files and restore them in the right place
main(); function main(){ //Make certain that user interaction (display of dialogs, etc.) is turned on. app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll; var myPageHeight = app.activeDocument.documentPreferences.pageHeight; var myPageWidth = app.activeDocument.documentPreferences.pageWidth; app.activeDocument.documentPreferences.pageWidth = myPageWidth -6; app.activeDocument.documentPreferences.pageHeight = myPageHeight -6; }
1 Correct answer
thanks all
the code works well now just a little problem with the bleed
#target indesign
var catalog = Folder.selectDialog ("/Users/lucclottemans/Desktop/BRIEFPAPIER_A4_R/");
if ( !catalog ) { exit(); }
var idml = [];
collectFiles ( catalog );
//$.writeln("FILE "+collectFiles);
alert ( idml.join( '\n' ) ) ;
for (var x= 0; x < idml.length; x++){
// app.activeDocument.save(File(fileName), true);
$.writeln("FILE"+ idml[x]);
app.open(idml[x]);
var myPageHeight = app.activeDocument.d
...
Copy link to clipboard
Copied
Have a look at the Adjust Layout facility to see if that can help resize your documents.
Copy link to clipboard
Copied
the resize code works well, I have to open all pages and resave as idml
var myFolder = new Folder("/Users/lucclottemans/Desktop/AFFICHE_A1_R/");
function scanSubFolders(tFolder, mask) { // folder object, RegExp or string
var sFolders = new Array();
var allFiles = new Array();
sFolders[0] = tFolder;
for (var j = 0; j < sFolders.length; j++){ // loop through folders
var procFiles = sFolders[j].getFiles();
for (var i=0;i<procFiles.length;i++){ // loop through this folder contents
if (procFiles[j] instanceof File ){
if(mask==undefined) allFiles.push(procFiles[j]);// if no search mask collect all files
// if (procFiles[j].fullName.search(mask) != -1) allFiles.push(procFiles[j]); // otherwise only those that match mask
allFiles.push(procFiles[j]);
}else if (procFiles[j] instanceof Folder){
sFolders.push(procFiles[j]);// store the subfolder
scanSubFolders(procFiles[j], mask);// search the subfolder
}
else {
}
}
}
return [allFiles,sFolders];
};
Copy link to clipboard
Copied
Hi,
try this snippet of code to collect all indd files down the folders tree. Then you got an array full of innd files to further process 🙂
regards
#target indesign
var catalog = Folder.selectDialog ('Select a folder.');
if ( !catalog ) { exit(); }
var indd = [];
collectFiles ( catalog );
alert ( indd.join( '\n' ) ) ;
function collectFiles ( folder ) {
var files = folder.getFiles();
for ( var i =0; i < files.length; i++ ) {
if ( files[i].constructor.name == 'File' && files[i].name.slice(-4) == 'indd' ) {
indd.push( files[i] );
}
if ( files[i].constructor.name == 'Folder' ) {
collectFiles ( files[i] );
}
}
}
Copy link to clipboard
Copied
Hi,
you could use your script with Peter Kahrel's Batch/Convert script that is also able to read IDML files.
Batch-process (convert/export/import) documents
by Peter Kahrel
https://creativepro.com/files/kahrel/indesign/batch_convert.html
Regards,
Uwe Laubender
( ACP )
Copy link to clipboard
Copied
thanks all
the code works well now just a little problem with the bleed
#target indesign
var catalog = Folder.selectDialog ("/Users/lucclottemans/Desktop/BRIEFPAPIER_A4_R/");
if ( !catalog ) { exit(); }
var idml = [];
collectFiles ( catalog );
//$.writeln("FILE "+collectFiles);
alert ( idml.join( '\n' ) ) ;
for (var x= 0; x < idml.length; x++){
// app.activeDocument.save(File(fileName), true);
$.writeln("FILE"+ idml[x]);
app.open(idml[x]);
var myPageHeight = app.activeDocument.documentPreferences.pageHeight;
var myPageWidth = app.activeDocument.documentPreferences.pageWidth;
app.activeDocument.documentPreferences.pageWidth = myPageWidth -6;
app.activeDocument.documentPreferences.pageHeight = myPageHeight -6;
documentPreferences.properties = {
documentBleedBottomOffset : 3,
documentBleedTopOffset : 3,
documentBleedInsideOrLeftOffset : 3,
documentBleedOutsideOrRightOffset : 3
}
app.activeDocument.save(idml[x]);
app.activeDocument.close();
}
function collectFiles ( folder ) {
var files = folder.getFiles();
for ( var i =0; i < files.length; i++ ) {
if ( files[i].constructor.name == 'File' && files[i].name.slice(-4) == 'idml' ) {
idml.push( files[i] );
}
if ( files[i].constructor.name == 'Folder' ) {
collectFiles ( files[i] );
}
//$.writeln("FILE "+collectFiles);
}
return idml;
}

