Skip to main content
August 7, 2011
Answered

Script for copying keywords to description field

  • August 7, 2011
  • 2 replies
  • 17354 views

Does anyone have a script that can be used in cs5 to copy the keywords to the description field?

Thanks

Mark

This topic has been closed for replies.
Correct answer gregreser

I don't use Capture One. Remember that read-only is a choice of the application developers. If its on your computer, it can be altered. Whether a specific app can do that altering is a different story.


@Lumigraphics is correct, there is no way in Bridge (in the app or via scripting) to change file Date Created.

ExifTool is your best bet to do the batch edit you want. 

ExifTool is an amazing tool but it is command line, which can be cumbersome if you're not used to it.

For what you want to do, I think this would be the command:

 

exiftool "-filecreatedate<datetimeoriginal" "DIR"

 

...where DIR is the name of a directory/folder containing the images. 

 

I tested this and it works for me, meaning when I read the file back through ExifTool the file date created is changed. Also, in Windows explorer the file date created is correct. Oddly, Bridge is still showing the original File Date Created value. I purged the folder cache, but that didn't help. Anyway, I think ExifTool is changing the file date, but Bridge has some issue showing it, so that's another puzzle to solve.

2 replies

Participating Frequently
June 16, 2022
Given a single folder of previously keyworded-images (jpg, raw, mp4) in Adobe Bridge 2022, a script for copying SELECT keywords to metadata Description/Subject Code field per image:  I found a Post by Paul Riggott dated Aug 7, 2011 providing Mark Wyco a Java Script how to do it on a MacI run Win10.  Furthermore, the displayed JSX code in the 2011 article had MUCH code lined-out, looking incomplete, giving me pause to load it into my Adobe Bridge 2022 app and precious images.
 
Requirements:
1. Run on Win10
2. Compatible with Adobe Bridge 2022
3. Auto cycle through ALL images in single folder
4. Copy USER SELECT POPUP keywords/image FROM Bridge XML? sidecar (or whereever they are stored?)
5. Paste USER SELECT POPUP keywords/image TO image's metadata's IPTC Core "Description" and/or IPTC Core "Subject Code" field. 
6. Reason for selected Keywords:  Limited space formatting on HDTV slideshows.
 
NOTE: Ultimate goal is ability to display one or more select Keywords in Description field/use Subject Code field when that image included in slideshows.  Hence, should PASTE be to IPTC Core "Description" field AND somehow use the IPTC Core "Subject Code" field?  Why? I've installed a Linux HDTV "Fotoxx" app that displays a so-called "Subject" field, which I'm thinking is related to the IPTC Core "Subject Code" field!  Maybe?
 
May I have help with generating and installing (I'm a novice at Bridge and JSX files?)
 
Thanks, Bob
RLMPhotos@ThriftyISP.com
gregreser
Legend
June 17, 2022

@X-T4Newbie Question about request 4

4. Copy USER SELECT POPUP keywords/image FROM Bridge XML? sidecar (or whereever they are stored?)

Do you want a popup (or dropdown list) that comes from keyword list that appears on the Bridge Keyword panel?

Paul Riggott
Inspiring
August 7, 2011

This should do it...


#target bridge  
if( BridgeTalk.appName == "bridge" ) { 
keysToDesc = MenuElement.create("command", "Keywords To Description", "at the end of Tools");
}
keysToDesc.onSelect = function () {
   keysToDesc();
   }
function keysToDesc(){
    function getArrayItems(ns, prop){
var arrItem=[];
var items = myXmp.countArrayItems(ns, prop);
   for(var i = 1;i <= items;i++){
     arrItem.push(myXmp.getArrayItem(ns, prop, i));
                }
return arrItem.toString();
}
if (ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");
var thumb = app.document.selections;
    for(var s in thumb){
if(thumb.hasMetadata){
        var selectedFile = thumb.spec;
  var myXmpFile = new XMPFile( selectedFile.fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_UPDATE);
  var myXmp = myXmpFile.getXMP();
        var Keywords = getArrayItems(XMPConst.NS_DC,'subject').replace(/,/g,';')
         myXmp.deleteProperty(XMPConst.NS_DC, "description");
        myXmp.setLocalizedText( XMPConst.NS_DC, "description", null, "x-default", Keywords );
    }
        if (myXmpFile.canPutXMP(myXmp)) {
        myXmpFile.putXMP(myXmp);
        myXmpFile.closeFile(XMPConst.CLOSE_UPDATE_SAFELY);
         } else {
  xmpFile.closeFile();
        }
    }
}
   

August 8, 2011

Thanks.

Um. now what?

I copied the text to a txt file, and saved it in the scripts folder.  do I rename it with a jsx extension?

I'm using a mac.

(btw, I'm a bit of a newbie to the mac bit.

I can write macros in visual basic for windows no problem)  Thanks. 

Stephen Marsh
Community Expert
Community Expert
October 4, 2018

Hi all,

I'm looking for the opposite approach! I have a client looking to turn thousands of photo descriptions into keywords. I've looked through the forums but couldn't find an answer to my problem. The  script needs to turn the description field in my metadata to individual keywords. Each space in between the words would need to be turned into a comma so bridge can read each word in my description as as separate keyword. Does anyone have a script like this?


OK, I have a two step approach. I can’t script, but sometimes I can hack them, so I have not worked out how to combine the two scripts into one (which is probably easy if you know what you are doing).

 

Work on copied files until you are 100% sure that testing results in what you are looking for!

 

STEP 1: First, run this script on the selected images, it will copy the description metadata to the keywords as single string:

 

// https://forums.adobe.com/thread/1075021
// NOTE: THIS IS AN INCOMPLETE WORKFLOW HACK, A SECOND SEPARATE SCRIPT MUST BE RUN TO SEPARATE THE DESCRIPTION STRING TO SEPARATE KEYWORDS
#target bridge  
if( BridgeTalk.appName == "bridge" ) {  
descTosubject = MenuElement.create("command", "Add Description to Subject/Keywords", "at the end of Tools");
}
descTosubject.onSelect = function () {
if (ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");
var thumb = app.document.selections;
    for(var s in thumb){
if(thumb.hasMetadata){
        var selectedFile = thumb.spec;
  var myXmpFile = new XMPFile( selectedFile.fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_UPDATE);
  var myXmp = myXmpFile.getXMP();
        var Description =  getArrayItems(XMPConst.NS_DC, "description");
        myXmp.deleteProperty(XMPConst.NS_DC, "subject");
        myXmp.appendArrayItem(XMPConst.NS_DC, "subject", Description, 0, XMPConst.ALIAS_TO_ALT_TEXT);
        myXmp.setQualifier(XMPConst.NS_DC, "subject[1]", "http://www.w3.org/XML/1998/namespace", "lang", "x-default");
    }
function getArrayItems(ns, prop){
var arrItem=[];
try{
var items = myXmp.countArrayItems(ns, prop);
for(var i = 1;i <= items;i++){
arrItem.push(myXmp.getArrayItem(ns, prop, i));
    }
return arrItem;
}catch(e){alert(e +" Line: "+ e.line);}
}
        if (myXmpFile.canPutXMP(myXmp)) {
        myXmpFile.putXMP(myXmp);
        myXmpFile.closeFile(XMPConst.CLOSE_UPDATE_SAFELY);
        } else {
  xmpFile.closeFile();
        }
    }
}

 

 

STEP 2: The second stage will be to run this script on the selected images, that will break each word separated by a space into a separate keyword:

 

// https://forums.adobe.com/thread/2415320
// https://forums.adobe.com/message/10658929#10658929
#target bridge
   if( BridgeTalk.appName == "bridge" ) {
sepkeys = MenuElement.create("command", "Seperate Keywords v2", "at the end of Tools");
}
sepkeys.onSelect  = function () {
var thumbs = app.document.selections;
if (ExternalObject.AdobeXMPScript == undefined)  ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");
var FolderName =  decodeURI(Folder(app.document.presentationPath).name);
for(var a =0;a<thumbs.length;a++){
var selectedFile =  new Thumbnail(thumbs);
app.synchronousMode = true;
var xmp = new XMPMeta(selectedFile.synchronousMetadata.serialize());
var keys = getArrayItems(XMPConst.NS_DC,"subject");
if(keys.length == 1){
xmp.deleteProperty(XMPConst.NS_DC,'subject');
keys = keys[0].toString().replace(/ /g,',').split(",");
for(var k in keys){
xmp.appendArrayItem(XMPConst.NS_DC, "subject", keys.toString(), 0,XMPConst.PROP_IS_ARRAY);
}
var newPacket = xmp.serialize(XMPConst.SERIALIZE_USE_COMPACT_FORMAT);
selectedFile.metadata = new Metadata(newPacket);
    }
}
ExternalObject.AdobeXMPScript.unload();
ExternalObject.AdobeXMPScript = undefined;
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;
};
};

 

Prepression: Downloading and Installing Adobe Scripts

_____________________

 

The equivalent ExifTool command can be used to perform this in a single step writing dc:subject metadata:

 

exiftool -overwrite_original -sep " " -tagsfromfile @ '-subject+<${description}' -r 'pathTOfileORfolder'

 

 

Or perhaps writing both dc:subject and legacy itpc:keywords at the same time:

 

exiftool -overwrite_original -use MWG -sep " " -tagsfromfile @ '-keywords+<${description}' -r 'pathTOfileORfolder'

_____________________

 

Again work on copied files until you are 100% sure of the results!