Script, move to layer above, save PSD
Hello friends, I am trying to automate a task in our office. I want to move to every layer above in point. At each point it stops, there is a staggered text field that I want to overlay on the frame at that time. I came up with this script but cannot get it to save the Photoshop file. Could someone with experience take a look. Any help or suggestions welcome. Thanks
if (app.project.activeItem != null && app.project.activeItem instanceof CompItem) {
var comp = app.project.activeItem;
var selectedLayers = comp.selectedLayers;
if (selectedLayers.length === 1) {
app.beginUndoGroup("Move Up Through InPoints");
var currentLayer = selectedLayers[0];
var fileIndex = 1; // Start file index
while (currentLayer.index > 1) {
// Get layer above
var layerAbove = comp.layer(currentLayer.index - 1);
// Move playhead to layerAbove's inPoint
comp.time = layerAbove.inPoint;
// Pause for a moment
$.sleep(1500);
// Select layerAbove
currentLayer.selected = false;
layerAbove.selected = true;
// **Automate Save Frame As Photoshop Layers**
var savePath = new File("C:/Temp/Test_" + fileIndex + ".psd");
app.executeCommand(app.findMenuCommandId("Save Frame As"));
app.executeCommand(app.findMenuCommandId("Photoshop Layers"));
// Increment index for unique filenames
fileIndex++;
// Step to next layer up
currentLayer = layerAbove;
}
app.endUndoGroup();
} else {
alert("Please select a single layer.");
}
} else {
alert("Please select a composition first.");
}
