Skip to main content
August 7, 2011
Answered

Script for copying keywords to description field

  • August 7, 2011
  • 2 replies
  • 17353 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
Brainiac
June 20, 2022

This is a sample script for reading and replacing data in the description field:

XMPdesc();        
        
        XMPdesc = function(){
            var descThumbs = app.document.selections; //get selected thumbnails
            var newText = 'test'; //replacement text
            if(!descThumbs.length) return; //nothing selected
            for(var a in descThumbs){ //loop through thumbs
                if(!descThumbs[a].container){ //not a folder
                    try{
                        var descMeta = descThumbs[a].synchronousMetadata; //get metadata
                        var descXMP = new XMPMeta(descMeta.serialize()); //serialize
                        alert(descMeta.read(XMPConst.NS_DC, 'description').toString()); //read description
                        descXMP.deleteProperty(XMPConst.NS_DC, 'description'); //delete
                        descXMP.setLocalizedText(XMPConst.NS_DC, 'description', null, 'x-default', newText); //set new description
                        var descUpdatedPacket = descXMP.serialize(XMPConst.SERIALIZE_OMIT_PACKET_WRAPPER | XMPConst.SERIALIZE_USE_COMPACT_FORMAT); //serialize
                        descThumbs[a].metadata = new Metadata(descUpdatedPacket); //write to file
                        }
                    catch(e){
                        alert(e + e.line);
                        }
                    }
                }
            }
gregreser
Brainiac
December 12, 2022

Woo Hoo!  Greg, the cleanup is done.  "Date" (taken) in Capture ONE now sorts proper.  Thanks for Metadata Deluxe which help narrow the field(s) to be updated.  Bob


You're very welcome. There are many questions about dates on the forum, so I'm hoping this script will be useful to a lot of people.

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. 

Paul Riggott
Inspiring
August 8, 2011

Hi Mark,

Copy and paste the script into ExtendScript Toolkit
This gets installed with Photoshop and can be found:-

<hard drive>/Applications/Utilities/Adobe Utilities

Start Bridge
Adobe Bridge menu - Preferences - Startup Scripts
At the bottom click the "Reveal Button" this will open the folder where the script should be saved.
Close and restart Bridge.
Accept the new script.

To use:
Select the documents you want to do the changes to, then Tools - Keywords To Description
This will then copy all the keyword to the description field.

Hope this helps.