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

Copy photoshop layer names and paste into IPTC keywords

Community Beginner ,
Nov 04, 2019 Nov 04, 2019

Copy link to clipboard

Copied

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?

TOPICS
Actions and scripting

Views

923

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 , Nov 05, 2019 Nov 05, 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.activeDo
...

Votes

Translate

Translate
Adobe
LEGEND ,
Nov 04, 2019 Nov 04, 2019

Copy link to clipboard

Copied

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

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 ,
Nov 04, 2019 Nov 04, 2019

Copy link to clipboard

Copied

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'

 

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 ,
Nov 05, 2019 Nov 05, 2019

Copy link to clipboard

Copied

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

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
New Here ,
Oct 27, 2022 Oct 27, 2022

Copy link to clipboard

Copied

//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);

 

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 ,
Oct 01, 2023 Oct 01, 2023

Copy link to clipboard

Copied

LATEST

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

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 Beginner ,
Nov 15, 2019 Nov 15, 2019

Copy link to clipboard

Copied

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?

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 ,
Nov 15, 2019 Nov 15, 2019

Copy link to clipboard

Copied

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

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 ,
Nov 18, 2019 Nov 18, 2019

Copy link to clipboard

Copied

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.

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 Beginner ,
Nov 18, 2019 Nov 18, 2019

Copy link to clipboard

Copied

Hi! Here's an update:

 

I posted a similar question on Photoshop Gurus and I was able to utilize the script at this link.

Photoshop Guru Script:

https://www.photoshopgurus.com/forum/threads/pull-layer-names-for-file-info-keywords.69966/#post-153...

 

Thanks for the help!

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
Participant ,
Oct 27, 2022 Oct 27, 2022

Copy link to clipboard

Copied

Hi Stephen,
Thanks for the link to the Photoshop Guru Script. That works great but I posted a request for a slight narrowing of it's scope. I need to narrow the layer names written to keywords to omly those found in a layerset called "Elements". If you or anyone else have any suggestions, it would be much appreciated.

Thanks,

https://www.photoshopgurus.com/forum/threads/pull-layer-names-for-file-info-keywords.69966/#post-153...

 

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