It works if I predefine an array with all the 6 images.
Instead I would like to have the script look in a certain folder and make an array of all the files in the folder.
See code below.
But it returns "ERROR: folderPath.getFiles is not a function".
With my Google searching it seems that getFiles should work.
Code: Select all
if (($error == null) && ($doc != null))
{
try {
// Define image folder
var folderPath = "D:\\TEST\\Place-images-InDesign\\images\\";
// Get the list of files in the folder
var images = folderPath.getFiles();
// Get the active document
var doc = $doc;
// Loop through each graphic frame
for (var i = 0; i < doc.rectangles.length; i++) {
// Place the image in the frame
doc.rectangles[i].place(images[i]);
// Fit the image to the frame
doc.rectangles[i].fit(FitOptions.FILL_PROPORTIONALLY);
}
$outfiles.push($outfile);
} catch (theError) {
$doc.close(SaveOptions.no);
$error = theError.description;
}
}