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

copy file name to keywords in Bridge CS6

New Here ,
Jul 29, 2015 Jul 29, 2015

Copy link to clipboard

Copied

Hello,

I need to create a process of copying the file name of a jpg to the keywords in Bridge CS6.  Ideally I need the script to parse the file name and use the words (not the symbols like "_" or "-") as keywords of the file.

Here's an example:

input

file name: jane_doe.jpg

keywords:

output

file name: jane_doe.jpg

keywords: jane doe

I don't know where to start with this scripting.  Any help or advise would be much appreciated! Perhaps you know of a really similar one that i can modify??

Thanks  in advance,

Claudia

TOPICS
Scripting

Views

758

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

Enthusiast , Jul 30, 2015 Jul 30, 2015

Please try this on selected files.

#target bridge  

   if( BridgeTalk.appName == "bridge" ) { 

filebits = MenuElement.create("command", "Add Filename bits to Keywords", "at the end of Tools");

}

filebits.onSelect = function () {

  var sels = app.document.selections;

  for (var i = 0; i < sels.length; i++){

var md = sels.synchronousMetadata;

var Filename = decodeURI(sels.name);

var nameParts = Filename.split(/-|_|\./);

nameParts.pop();

    md.namespace = "http://ns.adobe.com/photoshop/1.0/"

...

Votes

Translate

Translate
Enthusiast ,
Jul 30, 2015 Jul 30, 2015

Copy link to clipboard

Copied

Please try this on selected files.

#target bridge  

   if( BridgeTalk.appName == "bridge" ) { 

filebits = MenuElement.create("command", "Add Filename bits to Keywords", "at the end of Tools");

}

filebits.onSelect = function () {

  var sels = app.document.selections;

  for (var i = 0; i < sels.length; i++){

var md = sels.synchronousMetadata;

var Filename = decodeURI(sels.name);

var nameParts = Filename.split(/-|_|\./);

nameParts.pop();

    md.namespace = "http://ns.adobe.com/photoshop/1.0/";

    md.Keywords = md.Keywords + ";" + nameParts.join(',').replace(/,/g,';');

    }

};


					
				
			
			
				
			
			
			
			
			
			
			
		

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 ,
Aug 04, 2015 Aug 04, 2015

Copy link to clipboard

Copied

Thanks very much for the answer!  Big Help!!

Can you please clarify why "md.namespace" needs to be set and does it need to be the value you suggested in the code ?

Thanks again!!

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 ,
Aug 04, 2015 Aug 04, 2015

Copy link to clipboard

Copied

You need a namespace to get one of it's properties.

Here is an example of getting the keywords three different ways.

#target bridge;

if(app.document.selectionsLength>0){

var t = app.document.selections[0];     

var md = t.synchronousMetadata;

var Keywords = md.read("http://ns.adobe.com/photoshop/1.0/","Keywords").toString();

alert("Photoshop Namespace = " + Keywords);

/////////////////////////////////////////////////////////

var Keys = md.read("http://purl.org/dc/elements/1.1/","subject").toString();

alert("Dublin Core Namespace  = " +Keys);

//////////////////////////////////////////////////////////

if (ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript');

var xmpFile = new XMPFile( app.document.selections[0].spec.fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_READ);

var xmp = xmpFile.getXMP();

var keys = getArrayItems(XMPConst.NS_DC,'subject');

alert("Dublin Core again = " + keys.toString());

////////////////////////////////////////////////////////////

function getArrayItems(ns, prop){

var arrItem=[];

var items = xmp.countArrayItems(ns, prop);

for(var i = 1;i <= items;i++){

arrItem.push(xmp.getArrayItem(ns, prop, i));

}

return arrItem;

}

}

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 ,
Aug 04, 2015 Aug 04, 2015

Copy link to clipboard

Copied

LATEST

Great!  Thanks very much for your detailed information!  Much appreciated

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