Skip to main content
Participant
May 2, 2023
Question

Used ChatGPT to create a Javascript to place Images to separate pages into an INDD document

  • May 2, 2023
  • 1 reply
  • 392 views

Hope it helps someone with similar problem, this script places (in this case) .PSD files from desktop folder PSD to an opened INDD file, first 9 files need to have 01 to 09 names.:

 

// Define the folder path where the PSD files are stored
var folderPath = "~/Desktop/PSD/";

// Get a reference to the active document
var doc = app.activeDocument;

// Get a list of all the PSD files in the folder, sorted by name ascending
var files = Folder(folderPath).getFiles("*.psd");
files.sort(function(a, b) {
return a.name.localeCompare(b.name);
});

// Define the size of the frame to place the PSD file on
var frameWidth = 180;
var frameHeight = 310;

// Loop through each PSD file in the folder
for (var i = 0; i < files.length; i++) {
// Create a new page and place the PSD file on it
var page = doc.pages.add();
var rect = page.rectangles.add({
geometricBounds: [
(doc.documentPreferences.pageHeight - frameHeight) / 2,
(doc.documentPreferences.pageWidth - frameWidth) / 2,
(doc.documentPreferences.pageHeight + frameHeight) / 2,
(doc.documentPreferences.pageWidth + frameWidth) / 2
]
});
rect.place(files[i]);

// Match the frame size to the size of the placed file
rect.fit(FitOptions.CONTENT_TO_FRAME);
}

This topic has been closed for replies.

1 reply

Participant
May 2, 2023

ChatGPT is insane o_O