Попробуйте этот код
Он будет проходить по всем слоям и заменит его на файл .tiff, который вы выберете
var doc = app.activeDocument;
function editContent() {
cTID = function(s) { return app.charIDToTypeID(s); };
sTID = function(s) { return app.stringIDToTypeID(s); };
function Rename() {
// Edit Contents
function step1(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
executeAction(sTID('placedLayerEditContents'), desc1, dialogMode);
};
step1(); // Edit Contents
};
Rename.main = function () {
Rename();
};
Rename.main();
}
function merge() {
var fileRef = File.openDialog ('Choose File', ['*.tif;*tiff'], true);
app.open( new File( fileRef ) );
if(app.activeDocument.activeLayer.isBackgroundLayer ) app.activeDocument.activeLayer.name = 'From Background';
app.activeDocument.selection.selectAll();
app.activeDocument.selection.copy();
app.activeDocument.selection.deselect();
var idMk = charIDToTypeID( "Mk " );
var desc8946 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref1324 = new ActionReference();
var idBckL = charIDToTypeID( "BckL" );
ref1324.putClass( idBckL );
desc8946.putReference( idnull, ref1324 );
var idUsng = charIDToTypeID( "Usng" );
var ref1325 = new ActionReference();
var idLyr = charIDToTypeID( "Lyr " );
var idOrdn = charIDToTypeID( "Ordn" );
var idTrgt = charIDToTypeID( "Trgt" );
ref1325.putEnumerated( idLyr, idOrdn, idTrgt );
desc8946.putReference( idUsng, ref1325 );
executeAction( idMk, desc8946, DialogModes.NO );
app.activeDocument.close(SaveOptions.SAVECHANGES);
app.activeDocument.artLayers.add();
app.activeDocument.paste();
app.activeDocument.flatten();
app.activeDocument.close(SaveOptions.SAVECHANGES);
}
for (var i=0;i<doc.layers.length;i++){
doc.activeLayer=doc.layers[i];
editContent();
merge();
}