Skip to main content
Participant
November 4, 2019
Answered

Copy photoshop layer names and paste into IPTC keywords

  • November 4, 2019
  • 4 replies
  • 1810 views

Hi All,

I am looking for a way to easily use my Photoshop layer names as keywords to search for assets in Adobe Bridge (and beyond).

 

I am currently running a Mac on Mojave. When I use the finder, I can search for layer names and find the correct photoshop file. When I do the same search in Bridge, the file is not found. I believe that the layer name info is kept in the raw data within the sidecar XMP file. Bridge isn't searching for this information for some reason. I am thinking that if I can copy the layer names from the photoshop file, I should somehow be able to paste with semicolon separators into the IPTC keywords. At that point, the photoshop file will be searchable to specific layer names. 

 

If there are IPTC keywords in the XMP, that should be more easily searchable in Bridge and the file explorers for both windows and mac. Is this script available or even possible?

This topic has been closed for replies.
Correct answer Stephen Marsh

Much to my surprise, I managed to hack this script together. It works on the open document. It could be automatically run via the Script Events Manager when opening or saving a file. I have not performed exhaustive tests. Existing keyword metadata will be overwritten, I don't know how to append this metadata.

 

 

 

#target photoshop

// community.adobe.com/t5/Photoshop/Copy-photoshop-layer-names-and-paste-into-IPTC-keywords/m-p/10714597

/*
// Active layer name to keywords
var doc = app.activeDocument;
var layerName = doc.activeLayer.name;
var layerNameArray = new Array(layerName);
doc.info.keywords = layerNameArray;
alert('Keywords overwritten with active layer name');
*/

// gist.githubusercontent.com/vladocar/1628924/raw/a486566b2a648f94399fffa67dc9a2b4d681b86e/layerNames.js
// Get the top level layer names for groups and layers, layers in groups are ignored
var layerNum = app.activeDocument.layers.length;
var allLayers = [];
for (var i = 0; i < layerNum; i++) {
    allLayers[i] = app.activeDocument.layers[i].name; // RegEx placeholder - name.replace(/find/gi, 'replace')
}
// Add the top level layer names to keywords
app.activeDocument.info.keywords = allLayers;

alert('Keywords overwritten with top-level layer names!');

 

 

https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html

4 replies

Participant
November 15, 2019

Stephen_A_Marsh

 

This is a fantastic script! This works wonderfully, thank you so much. Would there be a way to access the layer names for all layers and not just the top layer level?

Stephen Marsh
Community Expert
Community Expert
November 15, 2019

Yes it is possible, however, I'll need to look into it.

Stephen Marsh
Community Expert
Community Expert
November 18, 2019

I'm happy for somebody else to step in! :]

 

This is a little more advanced and I have not had much luck searching for code to hack at.

Stephen Marsh
Community Expert
Stephen MarshCommunity ExpertCorrect answer
Community Expert
November 5, 2019

Much to my surprise, I managed to hack this script together. It works on the open document. It could be automatically run via the Script Events Manager when opening or saving a file. I have not performed exhaustive tests. Existing keyword metadata will be overwritten, I don't know how to append this metadata.

 

 

 

#target photoshop

// community.adobe.com/t5/Photoshop/Copy-photoshop-layer-names-and-paste-into-IPTC-keywords/m-p/10714597

/*
// Active layer name to keywords
var doc = app.activeDocument;
var layerName = doc.activeLayer.name;
var layerNameArray = new Array(layerName);
doc.info.keywords = layerNameArray;
alert('Keywords overwritten with active layer name');
*/

// gist.githubusercontent.com/vladocar/1628924/raw/a486566b2a648f94399fffa67dc9a2b4d681b86e/layerNames.js
// Get the top level layer names for groups and layers, layers in groups are ignored
var layerNum = app.activeDocument.layers.length;
var allLayers = [];
for (var i = 0; i < layerNum; i++) {
    allLayers[i] = app.activeDocument.layers[i].name; // RegEx placeholder - name.replace(/find/gi, 'replace')
}
// Add the top level layer names to keywords
app.activeDocument.info.keywords = allLayers;

alert('Keywords overwritten with top-level layer names!');

 

 

https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html

Participant
October 27, 2022

//To append instead of replacing the metadata in keywords, set the array to the keywords first and then use .push()

 

layerNameArray = app.activeDocument.info.keywords;

layerNameArray.push(allLayers);

 

Stephen Marsh
Community Expert
Community Expert
October 2, 2023

@Devon76 - Apologies for the late reply, I couldn't get this to work.

Stephen Marsh
Community Expert
Community Expert
November 4, 2019

This is possible in both Photoshop and Bridge. Bridge would probably be the best place to do such work, however, there are a lot less people around that can write Bridge scripts compared to Photoshop scripts.

 

This is easy enough to do using the free cross-platform ExifTool software:

 

exiftool -overwrite_original sep ',' tagsfromfile @ '-subject+<${PhotoshopLayerNames}' -r 'full FILE or DIRECTORY path'

 

This command is for the Mac OS, Windows OS would simply swap the single straight quotes for double straight quotes. The final argument would be changed to use the file system path to the file or top-level folder being recursively processed. Work on copies of the original files until you are happy, this command overwrites the originals. This command is only writing (appending) to XMP:Subject, not the legacy IPTC:Keywords. I’ll post new code for both.

 

EDIT: I can't get the MWG (Metadata Working Group) command to work correctly, which should write to both the XMP and legacy IPTC with one tag... So I have had to string together two commands:

 

exiftool -sep ',' '-subject+<${Photoshop:LayerNames}' -execute -sep ',' '-keywords+<${Photoshop:LayerNames}' -common_args -r 'fileORdirectoryPATH'

 

Kukurykus
Legend
November 4, 2019

There are also Bridge Scripting and (somewhere) XMP SDK forums.