【问题标题】:Photoshop script rename visible layer after filePhotoshop脚本在文件后重命名可见图层
【发布时间】:2018-12-04 22:02:11
【问题描述】:

你能帮我用一个 Photoshop 脚本在文件名之后重命名可见层吗?

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

谢谢,我很感激。

【问题讨论】:

    标签: photoshop layer


    【解决方案1】:

    例如这样:

    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()");
    

    【讨论】:

    • 嗨!是的,但是这个似乎只是重命名了第一层/图层组。可见层保留初始名称。谢谢。
    • 是的,它不能在群组中正常工作,我更新了我的答案
    • 你知道它是如何批量工作的吗?如果我打开多个文件,它只会重命名最后一个打开的文件。谢谢!
    • 只需循环浏览文档。另外,如果您能接受这个答案,我将不胜感激。
    • 它似乎只适用于某些 PS 版本。我尝试了 19 (CC 2018) 并且成功了。
    猜你喜欢
    • 2018-03-09
    • 1970-01-01
    • 2021-12-15
    • 2017-10-05
    • 2013-01-12
    • 1970-01-01
    • 2021-07-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多