Photoshop脚本在文件后重命名可见层

时间:2018-12-04 22:02:12

标签: photoshop layer

您能帮我一个用Photoshop脚本重命名文件名后的可见图层吗?

我必须处理大量的PS文件。

谢谢,谢谢。

1 个答案:

答案 0 :(得分:0)

例如:

function selectByID(id)
{
    var desc = new ActionDescriptor();
    var ref = new ActionReference();
    ref.putIdentifier(charIDToTypeID('Lyr '), id);
    desc.putReference(charIDToTypeID('null'), ref);
    executeAction(charIDToTypeID('slct'), desc, DialogModes.NO);
};

function traverseAllLayers(n)
{
    try
    {
        activeDocument.backgroundLayer;
        var layers = 0
    }
    catch (e)
    {
        var layers = 1;
    };
    while (true)
    {
        ref = new ActionReference();
        ref.putIndex(charIDToTypeID('Lyr '), layers);
        try
        {
            var desc = executeActionGet(ref);
        }
        catch (err)
        {
            break;
        }
        if (desc.getBoolean(charIDToTypeID("Vsbl")) && desc.getInteger(stringIDToTypeID("layerKind")) != 13) {
            var myId = desc.getInteger(stringIDToTypeID( 'layerID' ));
            selectByID(myId);
            activeDocument.activeLayer.name = activeDocument.name
        }
        layers++;
    }

};

app.activeDocument.suspendHistory("temp", "traverseAllLayers()");