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

Script to add description and keywords to files from text file

Participant ,
Dec 08, 2009 Dec 08, 2009

Copy link to clipboard

Copied

Can anyone write something up for me? I will admit I cannot do it myself, I do not know Javascript.

I need to add keywords and a description to 1000's of images. I have a text file formatted as such for each 100 images. The script would need to ask for an input file (or I can hardcode the path into the script) and then apply to the current folder of images shown in bridge.

Text file example:

1000 - Bright Sunset Over City. (sun;city;sky;mountain;) .

1001 - Dawn Behind Mountain And Lake. (sun;mountain;water;sky;) .

1002 - Bright Red Sunset, Light Edged Clouds. (sun;sky;tree;clouds;) .

1003 - Tree Framing Sunset Over Bay. (tree;sun;lake;bay;) .

1004 - Sun Behind Gull On Pilings. (seagull;sun;sea;pilings;) .

images are named 1000.tif, 1001.tif, 1002.tif etc

Running on a Mac with CS3 and CS4.

Thanks,

Chris

TOPICS
Scripting

Views

1.9K

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

Valorous Hero , Dec 09, 2009 Dec 09, 2009

Many thanks David, I must read up more on these things, I have amended the script as you noted.

Votes

Translate

Translate
Valorous Hero ,
Dec 08, 2009 Dec 08, 2009

Copy link to clipboard

Copied

This should work with CS3 or CS4. Hope it works for you.

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
Adobe Employee ,
Dec 08, 2009 Dec 08, 2009

Copy link to clipboard

Copied

Hi Paul,

This is nice example, but your script incorrectly sets both dc:description and dc:subject as ordered arrays. Description should be an alt-text type property, and subject is an unordered array (or 'bag'). Some software might not tolerate the incorrect XMP data types.

Here's an example showing the wrong and write way to set these two properties using the XMP Script API:

// load the library
if (ExternalObject.AdobeXMPScript == undefined) {
    ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");
}


var Desc = "Test Description";
var Keys = ["One","Two","Three"];


// The wrong way to set the Description. and Keywords...
var bogusXmp = new XMPMeta();
bogusXmp.appendArrayItem(XMPConst.NS_DC, "description", Desc, 0,XMPConst.ARRAY_IS_ORDERED);
for(var s in Keys){
      bogusXmp.appendArrayItem(XMPConst.NS_DC, "subject", Keys, 0,XMPConst.ARRAY_IS_ORDERED);
}
$.writeln( bogusXmp.dumpObject() );

// The correct way to set the Description and Keywords
var correctXmp = new XMPMeta();
correctXmp.setLocalizedText( XMPConst.NS_DC, "description", null, "x-default", Desc );
for(var s in Keys){
      correctXmp.appendArrayItem(XMPConst.NS_DC, "subject", Keys, 0,XMPConst.PROP_IS_ARRAY);
}
$.writeln( correctXmp.dumpObject() );

Thanks,

David

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 ,
Dec 09, 2009 Dec 09, 2009

Copy link to clipboard

Copied

Many thanks David, I must read up more on these things, I have amended the script as you noted.

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
Participant ,
Dec 09, 2009 Dec 09, 2009

Copy link to clipboard

Copied

Thanks so much!!! But, I can't get this to work. I feel pretty dumb... I've tried putting the script into my Bridge Startup Scripts folder, and I did not see any new menu item. I've tried to run it directly from Extendscript Toolkit for CS3 and CS4 with no real activity, no dialog asking for the text file, or I get an error that says "create redeclared". I'm going to assume that it's supposed to make a new menu item called "Add Description and Keywords from TXT file".

Thanks again,

Chris

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 ,
Dec 09, 2009 Dec 09, 2009

Copy link to clipboard

Copied

Either run ffrom ESTK or from the startup folder, the script will be available from the Right Mouse Click Menu.

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
Participant ,
Dec 09, 2009 Dec 09, 2009

Copy link to clipboard

Copied

Ah, OK I see, right click. Would have never thought of that.

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
Participant ,
Dec 09, 2009 Dec 09, 2009

Copy link to clipboard

Copied

Aha I got it working with some help from the Adobe Bridge SDK. I took the whole sample of "SnpAddMenuItem.jsx" and added in the functions from your script, and chagned the .onSelect function to do the updateDescKeys().

Works like a champ!

Thanks again!

Chris

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
Adobe Employee ,
Dec 09, 2009 Dec 09, 2009

Copy link to clipboard

Copied

Paul,

Thanks for helping out other users on the forum!

-David

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 ,
Jul 21, 2017 Jul 21, 2017

Copy link to clipboard

Copied

LATEST

As I don’t know how to script, I like to use these old threads to help me to learn how to do the same thing with ExifTool:

The .CSV data would be formatted as follows:

SourceFile,Description,Subject

/PATH_to_IMAGE_DIRECTORY/1000.tif,1000 - Bright Sunset Over City,"sun,city,sky,mountain"

/PATH_to_IMAGE_DIRECTORY/1001.tif,1001 - Dawn Behind Mountain And Lake,"sun,mountain,water,sky"

/PATH_to_IMAGE_DIRECTORY/1002.tif,"1002 - Bright Red Sunset, Light Edged Clouds","sun,sky,tree,clouds"

This was an interesting case (line 4 and the multiple keywords), as one can’t use commas in a CSV to separate other data, so one has to enclose the unwanted text containing commas with quote marks.

Then to import, the following ExifTool command would be used:

exiftool -r -sep ', ' -csv='/PATH_to_CSV/input.csv' '/PATH_to_IMAGE_DIRECTORY'

This example is formatted on the Mac OS, minor modifications would be needed to run on Windows (most likely changing single straight quotes to double straight quotes and possibly vice versa with double quotes).

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