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

Script for copying keywords to description field

Guest
Aug 07, 2011 Aug 07, 2011

Copy link to clipboard

Copied

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

Thanks

Mark

TOPICS
Scripting

Views

6.4K

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 , Dec 08, 2022 Dec 08, 2022

@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

...

Votes

Translate

Translate
replies 144 Replies 144
Valorous Hero ,
Aug 07, 2011 Aug 07, 2011

Copy link to clipboard

Copied

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();
        }
    }
}
   

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
Guest
Aug 07, 2011 Aug 07, 2011

Copy link to clipboard

Copied

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. 

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
Valorous Hero ,
Aug 08, 2011 Aug 08, 2011

Copy link to clipboard

Copied

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.

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
Contributor ,
Apr 16, 2017 Apr 16, 2017

Copy link to clipboard

Copied

This might solve my issue, but there is no "<hard drive>/Applications/Utilities/Adobe Utilities" and i can't find any instance of ExtendScript on my hard drive. are these instructions for Mac OS? I have Win10.

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 ,
Apr 16, 2017 Apr 16, 2017

Copy link to clipboard

Copied

jaebaeli​ you don’t really need ExtendScript Toolkit, any text editor such as Notepad.exe will do. Just make sure that your script is saved with a .jsx filename extension rather than .txt

Yes, that path was for the Mac, the forward slashes in the filepath and the word Applications are a dead giveaway for those that know that OS. For Windows, try:

C:\Program Files\Adobe\Adobe Utilities\ExtendScript Toolkit\ExtendScript Toolkit.exe

Of course, simply having a valid Bridge .js or jsx file is not enough – you will also need to know where to install the script.

Open Bridge and to into Preferences (CMD/CTRL K) – then look for the Startup Scripts category. Next, press the “Reveal My Startup Scripts” button. This will open the correct folder/directory window for you to move the .jsx file into. Then quit Bridge and then re-launch Bridge again and you should be asked to enable the new startup script. If you do not see this message, ensure that there is a tick/checkmark against the script in your preferences.

Good luck!

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
Contributor ,
Apr 16, 2017 Apr 16, 2017

Copy link to clipboard

Copied

(tried to edit my first post, but the Actions menu wouldn't generate the edit option) Here's the thread i started about my issue with the tags, FYI Re: Include tags in other metadata areas?

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 ,
Apr 16, 2017 Apr 16, 2017

Copy link to clipboard

Copied

Indeed, I am happy to help if you can reply to my questions and or supply a sample file containing the required metadata.

I am not sure if what you wish to do can be accomplished with Bridge scripting, however until the source and destination fields are known I can’t say. That being said, I can also help with ExifTool as a fallback option if this can’t be achieved using scripts in Bridge.

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 04, 2018 Oct 04, 2018

Copy link to clipboard

Copied

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?

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 04, 2018 Oct 04, 2018

Copy link to clipboard

Copied

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!

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 05, 2018 Oct 05, 2018

Copy link to clipboard

Copied

It worked perfectly! Thank you so much!

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 05, 2018 Oct 05, 2018

Copy link to clipboard

Copied

My pleasure, glad to 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
New Here ,
Oct 13, 2018 Oct 13, 2018

Copy link to clipboard

Copied

This is amazing, but I'd like to copy keywords to the description field (the reverse) so that I can get google photos to recognize the terms.

But it is not as easy as just flipping the category codes in the first script. I tried and it doesn't work.


Can you help me figure out what I need to change?

Thanks

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 13, 2018 Oct 13, 2018

Copy link to clipboard

Copied

That is what Paul’s original script in reply #1 should do, copy keywords to description:

Re: Script for copying keywords to description field

P.S. The basic ExifTool command on Mac OS would be:

exiftool -overwrite_original '-description<$subject' -r 'pathTOfileORfolder'

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
Contributor ,
Aug 09, 2013 Aug 09, 2013

Copy link to clipboard

Copied

I think at the end of the code:

xmpFile.closeFile();

is a typo error, and the correct is:

myXmpFile.closeFile();

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 ,
Jun 16, 2022 Jun 16, 2022

Copy link to clipboard

Copied

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

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 ,
Jun 16, 2022 Jun 16, 2022

Copy link to clipboard

Copied

@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?

keyword_panel-001.jpg

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 ,
Jun 18, 2022 Jun 18, 2022

Copy link to clipboard

Copied


@X-T4Newbie wrote:
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.

 

If the script doesn't work with Bridge, there will be an error and then all you need to do is uninstall. When testing a script, always work on a copy of your precious images until you are happy with the results.

 

The forum software has gone through some changes, old posts don't always display as originally intended.

 

I have a copy in my archive from 2017 for a similar script:

 

// https://forums.adobe.com/thread/1223292
// https://forums.adobe.com/thread/2318450

#target bridge

if (BridgeTalk.appName === "bridge") {
    keysToDescription = MenuElement.create("command", "Keywords To Description (v2017)", "at the end of Tools");
}
keysToDescription.onSelect = function () {
    var sels = app.document.selections;
    for (var a in sels) {
        md = sels[a].synchronousMetadata;
        md.namespace = "http://ns.adobe.com/photoshop/1.0/";
        var Keys = md.Keywords.toString().replace(/,/g, ', '); // Replace a comma with comma space  
        md.namespace = "http://purl.org/dc/elements/1.1/";
        md.description = '';
        md.description = Keys;
        app.document.chooseMenuItem("PurgeCacheForSelected");

    }
};

 

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
Community Expert ,
Jun 18, 2022 Jun 18, 2022

Copy link to clipboard

Copied


@X-T4Newbie wrote:
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?

 

You should populate all available metadata fields with descriptive text and test before anybody spends time on the assumption that this is the correct field.

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 ,
Jun 18, 2022 Jun 18, 2022

Copy link to clipboard

Copied

Stephen is right, you need to first determine which metadata fields Fotoxx is using. I have a feeling it's not IPTC Subject Code because that is an 8-digit code from the IPTC Subject NewsCode Controlled Vocabulary (see: http://cv.iptc.org/newscodes/subjectcode).

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 ,
Jun 30, 2022 Jun 30, 2022

Copy link to clipboard

Copied

" Stephen is right, you need to first determine which metadata fields Fotoxx is using. I have a feeling it's not IPTC Subject Code because that is an 8-digit code from the IPTC Subject NewsCode Controlled Vocabulary (see: http://cv.iptc.org/newscodes/subjectcode). "

============

 

Hi Guys, sorry for extreme delay (got Linux/Fotoxx reinstalled and working) responding to your advice about copying specific Metadata into Fotoxx's slideshow "Caption-Abstract" field.   I've proven that if select Keyword(s) are copied into the metadata "Description" field, it is displayed during a slideshow as the Fotoxx "Caption-Abstract" field per image.  So now, my question to you:  Can the Adobe Bridge script you provided me provide a "popup list" of hierachical keywords from metadata's "HierarchicalSubject" list per each image?  Then, for example, I might choose an Event or People or Place HierarchicalSubject, as there's limited room to display all Keywords info.  Thank you for the help.  (BTW: I get a first position, first line Adobe Bride 2022 error when trying to install the Script you guys already provided me.  Any idea what JSX error I'm making as a newbie?)  Thanks, Bob  

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
LEGEND ,
Jun 20, 2022 Jun 20, 2022

Copy link to clipboard

Copied

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

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 ,
Jun 20, 2022 Jun 20, 2022

Copy link to clipboard

Copied

I have an idea for the UI, but I need more information on the requirements @X-T4Newbie 

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 ,
Jun 21, 2022 Jun 21, 2022

Copy link to clipboard

Copied

Thank you all for replies to this Adobe Bridge newbie,  @X-T4Newbie.

I've not had chance to try the macros provided.  But some simple feedback:  As my Keywords are hieracial in Bridge on right side of page (like example Stephen provided at top of thread), it would be alot easier to select a FEW select keywords for Description/Subject, rather than listing them ALL during a slideshow to family members... if that is even possible to resresent by script!?   Try hard to copy/install/execute JSX first provided soon given simple instructions how.   (Ran into a RPi Linux problem today - which I'm a novice at too.  Have to reinstall custom OS....)   But Thank you.  X-T4Newbie  

 

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 ,
Jun 21, 2022 Jun 21, 2022

Copy link to clipboard

Copied

P.S. Important along with select Keywords is to also pickup the Date Originally Created from EXIF.  For example, if available, I'd concatenate <"YYYYMMDD"> (an EXIF field) <Los Angeles"> (a select keyword) <"Christmas"> (a select keyword).  

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