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

Script to copy file name to keywords

Community Beginner ,
Dec 13, 2021 Dec 13, 2021

Copy link to clipboard

Copied

I am trying to add a script copy my filenames to IPTC Keywords without the file extension in Bridge ver12. I have tried three different scripts from older discussion chains (2010-16) and none seem to be working. I did add the Utlity Script Pack and the script to move File Name to the IPTC Title and it is working. Can anyone help?

TOPICS
How to , Keywords , Metadata , Scripting

Views

199

Likes

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 ,
Dec 13, 2021 Dec 13, 2021

Copy link to clipboard

Copied

Are you sure you want to write filename to keywords? If you had 100 files, you'd have 100 keywords with each only used in one file. That doesn't seem very useful to me.

Likes

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 ,
Dec 13, 2021 Dec 13, 2021

Copy link to clipboard

Copied

As you can probably tell I am a newbie at Adobe, but I do have about 13,000 photos, most of which are scanned with no useful Meta data. However the file names are very specific to the content of the photo. I would like to be able to search aganst these terms in  Lightroom and other places that Keywords are searchable. The files are JPG and the names all have the a similar syntax. 

 

File Name Syntax - Year, Initals of People of Key People, Location or Event. All these have spaces in between words.

Ex: "2018 JT HT MT High School Graduation.jpg"

 

Based on your response I assume I would need to add a delimitor between each item to make each item independently searchable?  

Likes

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 ,
Dec 14, 2021 Dec 14, 2021

Copy link to clipboard

Copied

What is the desired text pattern?

 

Something like:

2018;JT;HT;MT;High School Graduation.jpg

or

2018;JT;HT;MT;High School;Graduation.jpg

 

My simple example breaking on every space would create: High;School;Graduation as three separate keywords, I'm guessing that this should be one keyword or perhaps two words with Graduation broken out separately from High School? Are there other graduation shots that may need to be handled, such as College Graduation?

 

It should be possible to script the desired pattern to create appropriate keywords without having to change your existing filenames.

 

Likes

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 ,
Dec 14, 2021 Dec 14, 2021

Copy link to clipboard

Copied

LATEST

You can search on filename pretty much anywhere. The problem here isn't technical, its using keywords in a way that doesn't fit their purpose. I'll just say I advise against setting up a system where you rely on this. Having 13,000 keywords is NOT going to work well.

Likes

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 ,
Dec 13, 2021 Dec 13, 2021

Copy link to clipboard

Copied

 

This one works for me in Bridge 2022, the entire filename is added as a single keyword:

 

// https://forums.adobe.com/thread/656144
#target bridge   
addNametoMeta = {};   
addNametoMeta.execute = function(){   
  var sels = app.document.selections;   
  for (var i = 0; i < sels.length; i++){   
var md = sels[i].synchronousMetadata;   
    md.namespace = "http://ns.adobe.com/photoshop/1.0/";   
    var Name = decodeURI(sels[i].name).replace(/\.[^\.]+$/, '');  
    md.Keywords = md.Keywords + ";" + Name;   
  }   
}   
if (BridgeTalk.appName == "bridge"){   
var menu = MenuElement.create( "command", "Save Filename in Keywords", "at the end of Tools");   
  menu.onSelect = addNametoMeta.execute;   
}  

 

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

 

Likes

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 ,
Dec 13, 2021 Dec 13, 2021

Copy link to clipboard

Copied

Thanks so much Stephen - the script worked.

Likes

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 ,
Dec 14, 2021 Dec 14, 2021

Copy link to clipboard

Copied

 

Each filename would be a single long keyword, so yes a modification should be used to break them into separate useful components.

 

This modified version will create a new keyword for each word space separator in the filename:

 

// https://forums.adobe.com/thread/656144
#target bridge
addNametoMeta = {};
addNametoMeta.execute = function () {
  var sels = app.document.selections;
  for (var i = 0; i < sels.length; i++) {
    var md = sels[i].synchronousMetadata;
    md.namespace = "http://ns.adobe.com/photoshop/1.0/";
    var Name = decodeURI(sels[i].name).replace(/\.[^\.]+$/, '').replace(/ /g, ';');
    md.Keywords = md.Keywords + ";" + Name;
  }
}
if (BridgeTalk.appName == "bridge") {
  var menu = MenuElement.create("command", "Filename to Keywords Space Separated", "at the end of Tools");
  menu.onSelect = addNametoMeta.execute;
}  

 

 

Likes

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