Can you fix this script? It is for Photoshop. const exportFolder = new…
- User
Can you fix this script? It is for Photoshop. const exportFolder = new Folder(Folder.desktop + "/Photoshop Export");
// Create the export folder if it doesn't exist if (!exportFolder.exists) { exportFolder.create(); }
function exportLayersAsJPG() { const doc = app.activeDocument; const docName = doc.name.replace(/.psd$/i, ''); // Use regex to remove the .psd extension
codefor (let i = 0; i < doc.artLayers.length; i++) { const layer = doc.artLayers[i]; if (!layer.visible) continue; // Skip non-visible layers // Duplicate the current document const tempDoc = doc.duplicate(); // Hide all layers in the duplicated document except for the current layer for (let j = 0; j < tempDoc.artLayers.length; j++) { tempDoc.artLayers[j].visible = (i === j); } // Merge visible layers (which will be just one layer at this point) tempDoc.flatten(); const fileName = `${docName} - ${layer.name}.jpg`; const filePath = `${exportFolder.fullName}/${fileName}`; const jpegOptions = new JPEGSaveOptions(); jpegOptions.quality = 11; // Set JPEG quality // Save and close the temporary document tempDoc.saveAs(new File(filePath), jpegOptions, true, Extension.LOWERCASE); tempDoc.close(SaveOptions.DONOTSAVECHANGES); }}
exportLayersAsJPG();
- Assistant
- User
Error 25 on Line 16. Please double check and make sure that script is working before sending.
- Assistant
- User
Are we using const in photoshop scripting?
- Assistant