Gotcha thats no problem! I've been using the script a bit today and was wondering about a couple things. Let me know what you think.
1. Is there a way to only have the script save just the smart object file instead of all the files since the smart object file is the only one that changes and updates the rest?
2. How do I change the export quality of the smart object file export to max it out?
3. At the end of the script, there is a script alert indicating the success of the execution, and then it opens the export folder. Is there a way to remove these occurrences?
1. Is there a way to only have the script save just the smart object file instead of all the files since the smart object file is the only one that changes and updates the rest?
@MasterCrod103
Sure, I was assuming that you would wish all files to be "synchronised", but this is easy to do by deleting the appropriate chunk of code.
2. How do I change the export quality of the smart object file export to max it out?
By adjusting the quality value from 70 to 100. I have changed this for independent control, the 4K image is now saved at 100 quality, however the smaller JPEG files are still saved at 70. How it was previously setup was the same value for both.
3. At the end of the script, there is a script alert indicating the success of the execution, and then it opens the export folder. Is there a way to remove these occurrences?
You can either delete or comment out the code, I have done both in the updated 1.1 version below:
/*
Save JPEG Versions from Templates v1-0.jsx
https://community.adobe.com/t5/photoshop-ecosystem-discussions/batch-replace-smart-objects-script-using-a-linked-file-for-multiple-files/m-p/13568165
v1.1 16th February 2023, Stephen Marsh
Notes:
* All 10 files must be open...
* The 'Placeholder_Screen.psb' should have been manually updated with the new content and saved.
* All of the 9 template files should have been automatically updated from the linked smart object placeholder.
* Run the script, it will create the new output folder and JPEG versions at 3840x2160px and 2000x1600px size.
*/
#target photoshop
(function () {
if (documents.length === 10) {
try {
// Save the "Placeholder_Screen.psb" document
activeDocument = documents.getByName("Placeholder_Screen.psb");
activeDocument.artLayers.add();
activeDocument.activeLayer.name = "_T-E-M-P_";
activeDocument.activeLayer.remove();
activeDocument.save();
// Create the next folder
var lastDirPath = Folder.selectDialog("Please select the last 'TV####' folder:", "~/Desktop/Batch Replace SO/Tests/Samsung TV Frame Art");
if (lastDirPath === null) {
alert('Script cancelled!');
return;
}
var lastDigits = lastDirPath.name.replace(/TV0/, "");
lastDigits = Number(lastDigits) + 1;
var newDirName = "TV0" + lastDigits;
var newDirPath = Folder(lastDirPath.parent);
var newDir = Folder(decodeURI(newDirPath + "/" + newDirName));
if (!newDir.exists) newDir.create();
// Export the SO file at native 3840x2160px size
var saveFileJPEG = new File(newDirPath + "/" + newDirName + "/" + newDirName + ".jpg");
SaveForWeb(100, saveFileJPEG);
activeDocument.close(SaveOptions.DONOTSAVECHANGES);
// Loop over the open template files and save 2000x1600px JPEG versions to the same folder
while (app.documents.length > 0) {
var origUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
var docName = activeDocument.name.replace(/\.[^\.]+$/, '');
activeDocument.resizeImage(2000, null, null, ResampleMethod.BICUBIC);
var saveFileJPEG = new File(newDirPath + "/" + newDirName + "/" + docName + ".jpg");
SaveForWeb(70, saveFileJPEG);
activeDocument.close(SaveOptions.DONOTSAVECHANGES);
app.preferences.rulerUnits = origUnits;
}
// End of script
//app.beep();
} catch (e) {
alert("The file 'Placeholder_Screen.psb' isn't open!");
}
} else {
alert("Only the 10 required template/placeholder files should be open!");
}
}());
///// Functions /////
function SaveForWeb(qValue, saveFileJPEG) {
var sfwOptions = new ExportOptionsSaveForWeb();
sfwOptions.format = SaveDocumentType.JPEG;
sfwOptions.includeProfile = true;
sfwOptions.interlaced = 0;
sfwOptions.optimized = true;
sfwOptions.quality = qValue;
app.activeDocument.exportDocument(saveFileJPEG, ExportType.SAVEFORWEB, sfwOptions);
}