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
Many thanks David, I must read up more on these things, I have amended the script as you noted.
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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
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.
Copy link to clipboard
Copied
Ah, OK I see, right click. Would have never thought of that.
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
Copy link to clipboard
Copied
Paul,
Thanks for helping out other users on the forum!
-David
Copy link to clipboard
Copied
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).