• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

A script or something that would make layer names a psd file keywords ?

Enthusiast ,
Sep 20, 2021 Sep 20, 2021

Copy link to clipboard

Copied

Or would rather do it for selected grops , smart objects, layers and layer comps . I mean you select things and the script put their names in file keywords   so you coould later  search quickly for sertain things in your DAM

TOPICS
macOS , Windows

Views

284

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Sep 21, 2021 Sep 21, 2021
// add selected layers’ names to keywords;
// 2021, use it at your own risk;
#target photoshop
if (app.documents.length > 0) {
    var myDocument = app.activeDocument;
    var theLayers = collectSelectedLayersBounds ();
    var theKeywords = myDocument.info.keywords;
    for (var m = 0; m < theLayers.length; m++) {
        var thisName = theLayers[m][0];
        var theCheck = true;
        for (var n = 0; n < theKeywords.length; n++) {
            if (thisName == theKeywords[n]) {theCheck = fal
...

Votes

Translate

Translate
Adobe
Community Expert ,
Sep 20, 2021 Sep 20, 2021

Copy link to clipboard

Copied

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Sep 21, 2021 Sep 21, 2021

Copy link to clipboard

Copied

LATEST

Thanks a lot Stephen ,   neighter of those scripts do it for selected layers  although .  When doing it to all layers it creates a lot of senceless junk in keyword lists  like layer1 coppy2  etc.  My guess it would stress any DAM system with lots of  junk keywords .   

I wonder if it's possible to modify somehow to work for selected only . MAybe group names ?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 21, 2021 Sep 21, 2021

Copy link to clipboard

Copied

// add selected layers’ names to keywords;
// 2021, use it at your own risk;
#target photoshop
if (app.documents.length > 0) {
    var myDocument = app.activeDocument;
    var theLayers = collectSelectedLayersBounds ();
    var theKeywords = myDocument.info.keywords;
    for (var m = 0; m < theLayers.length; m++) {
        var thisName = theLayers[m][0];
        var theCheck = true;
        for (var n = 0; n < theKeywords.length; n++) {
            if (thisName == theKeywords[n]) {theCheck = false}            
        };
        if (theCheck == true) {theKeywords.push(thisName)};
    };
    myDocument.info.keywords = theKeywords;
    alert (myDocument.info.keywords.join("\n"));
};
////// collect bounds of selected layers //////
function collectSelectedLayersBounds () {
// set to pixels;
    var originalRulerUnits = app.preferences.rulerUnits;
    app.preferences.rulerUnits = Units.PIXELS;
// get selected layers;
    var selectedLayers = new Array;
    var ref = new ActionReference();
    ref.putEnumerated( charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
    var desc = executeActionGet(ref);
    if( desc.hasKey( stringIDToTypeID( 'targetLayers' ) ) ){
    desc = desc.getList( stringIDToTypeID( 'targetLayers' ));
    var c = desc.count;
    var selectedLayers = new Array();
// run through selected layers;
    for(var i=0;i<c;i++){
    try{activeDocument.backgroundLayer;
    var theIndex = desc.getReference( i ).getIndex();
    }catch(e){var theIndex = desc.getReference( i ).getIndex()+1 };
// get id for solid color layers;
    try {
    var ref = new ActionReference();
    ref.putIndex( charIDToTypeID("Lyr "), theIndex ); 
    var layerDesc = executeActionGet(ref);
    var theName = layerDesc.getString(stringIDToTypeID('name'));
    var theIdentifier = layerDesc.getInteger(stringIDToTypeID ("layerID"));
    var theBounds = layerDesc.getObjectValue(stringIDToTypeID("bounds"));
    var theseBounds = [theBounds.getUnitDoubleValue(stringIDToTypeID("left")), theBounds.getUnitDoubleValue(stringIDToTypeID("top")), theBounds.getUnitDoubleValue(stringIDToTypeID("right")), theBounds.getUnitDoubleValue(stringIDToTypeID("bottom"))];
    selectedLayers.push([theName, theIdentifier, theseBounds]);
    } catch (e) {};
    };
// if only one:
    }else{
    var ref = new ActionReference();
    ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
    var layerDesc = executeActionGet(ref);
    try {
    var theName = layerDesc.getString(stringIDToTypeID('name'));
    var theIdentifier = layerDesc.getInteger(stringIDToTypeID ("layerID"));
    var theBounds = layerDesc.getObjectValue(stringIDToTypeID("bounds"));
    var theseBounds = [theBounds.getUnitDoubleValue(stringIDToTypeID("left")), theBounds.getUnitDoubleValue(stringIDToTypeID("top")), theBounds.getUnitDoubleValue(stringIDToTypeID("right")), theBounds.getUnitDoubleValue(stringIDToTypeID("bottom"))];
    selectedLayers = [[theName, theIdentifier, theseBounds]]
    } catch (e) {};
    };
// reset;
    app.preferences.rulerUnits = originalRulerUnits;
    return selectedLayers;
};

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines