Question
Error 4 in Phtoshop jsx script
Hi all,
I've tried to write a script to process 800 high resolution files that I have - I need to resize them to smaller dimensions, place another image on top of them and save with a new filename. With below script it fails with Error 4 on Line 2. Adobe Photoshop has full permission to folders on my device.
// Define the folder containing the files
var folderPath = "/Users/drcs/Desktop/Circuits/To print/Cropped_lowres/tracks/”;
// Define the path to the image to be placed on top
var overlayImagePath = "/Users/drcs/Desktop/Circuits/To print/Cropped_lowres/tracks/frame.png”;
// Open all files in the folder
var files = Folder(folderPath).getFiles(„*.png”); // Adjust the file extension if needed
// Open the overlay image
var overlayFile = new File(overlayImagePath);
var overlayDoc = app.open(overlayFile);
// Loop through each file
for (var i = 0; i < files.length; i++) {
var file = files[i];
// Open the file
var doc = app.open(file);
// Duplicate the overlay image
var overlayLayer = overlayDoc.artLayers[0];
overlayLayer.duplicate(doc, ElementPlacement.PLACEATBEGINNING);
// Close the overlay document without saving changes
overlayDoc.close(SaveOptions.DONOTSAVECHANGES);
// Resize the image
doc.resizeImage(2480, 3543);
// Save the modified image under a new filename
var fileName = file.name.slice(0, -4); // Remove the file extension (.png)
var newFileName = fileName + „_framed.png”; // Append "_resized" to the original filename
var newFile = new File(folderPath + newFileName); // Construct the new file path
doc.saveAs(newFile);
// Close the document
doc.close();
}
Any chance that you can help with this one guys?
