Skip to main content
Participating Frequently
August 2, 2005
Question

Script to Export and Import Keywords and Metadata

  • August 2, 2005
  • 37 replies
  • 10452 views
I have a requirement to mass upload and download keywords and various metadata fields (i.e. File Name, Date Created, City, Country, Document, Title, etc.) into an external database from the Adobe Bridge. Ideally it would be compatible to .txt, .csv, etc type of database format. Currently I have to accomplish this task one at a time. I have an immediate need to upload 1000 plus pictures and various text fields into my website to share with others and be able to sell my pictures online.

My immediate is for exporting the metadata and keywords.

Does anyone know of a script that is aavailable?

Arnold
This topic has been closed for replies.

37 replies

Participating Frequently
August 5, 2005
John,

Thanks for your quick response. Below is the script I just modified this morning. When looking in the keyword field, it returns the word "undefined" for all records.

I tried that yesterday and it didn't work. When looking at the Advance file info on Adobe Bridge I see the below format which had 2 levels. All the others I used only had one. Since I am not a programmer, I need help on that part of the script.

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

EXIF Properties (exif,http://ns.adobe.com/exif/1.0/)
- exif:Flash
- exif:Fired: True

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

Any luck on determining how to obtain file size.

Again thank you so much for supporting me on my project,

Arnold

=====================
#target bridge

if (BridgeTalk.appName == "bridge")
{
// Let's create our menu
var menu = MenuElement.create( "command", "Export CSV File", "at the end of Tools");
menu.onSelect = function(m) {
try
{
// Let's ask what the name of the output file
var f = File.saveDialog("Export file list to:", "Comma delimited file:*.CSV");

// Write the column headings
f.open("w");
f.writeln("Seq Number,New File Name,New File Name Path,Original File Name,Org Dt & Tm,ISO,Exposure Time,F Stop,EV,Exposure Program,Meter Mode,Focal Length,Flash,Lens,Author, Author's Position,City,Country,Description,Title,Orientation,Width,Height,Rating,Label");

// Let's get a list of all the visible thumbnails
var items = app.document.visibleThumbnails;

for (var i = 0; i < items.length; ++i) { var item = items; f.writeln(i + 1, ",\"", item.name, "\",\"", item.path.replace(/\"/g, "\"\""), "\",\"", ListMetadata(item), "\",\"", "\"" ); } f.close(); } catch(e) { } } menu.onDisplay = function(m) { m.enabled = app.document.contentPaneMode == "filesystem" && app.document.visibleThumbnails.length > 0;
}
}

function ListMetadata(tn)
{
md = tn.metadata;
md.namespace = "http://ns.adobe.com/photoshop/1.0/";
varAuthor = md.Author + "\",\"" + md.AuthorsPosition + "\",\"" + md.City + "\",\"" + md.Country + "\",\"";

md.namespace = "http://ns.adobe.com/exif/1.0/aux/";
varLens = md.Lens + "\",\"" ;

md.namespace = "http://purl.org/dc/elements/1.1/";
vartitle = md.title + "\",\"" + md.description + "\",\"" ;

md.namespace = "http://ns.adobe.com/xap/1.0/mm/"
VarPreservedFileName = md.PreservedFileName + "\",\"" ;

md.namespace = "http://ns.adobe.com/exif/1.0/"
VarDateTimeOriginal = md.DateTimeOriginal + "\",\"" + md.ISOSpeedRatings + "\",\"" + md.ExposureTime + "\",\"" + md.FNumber + "\",\"" + md.ExposureBiasValue + "\",\"" + md.ExposureProgram + "\",\"" + md.MeteringMode + "\",\"" + md.FocalLengthIn35mmFilm + "\",\"" + md.Flash + "\",\"" ;

md.namespace = "http://ns.adobe.com/tiff/1.0/"
varOrientation = md.Orientation + "\",\"" + md.ImageWidth + "\",\"" + md.ImageLength + "\",\"" ;

md.namespace = "http://ns.adobe.com/xap/1.0/"
varRating = md.Rating + "\",\"" + md.Label ;

md.namespace = "http://ns.adobe.com/photoshop/1.0/";
varKeywords = ListKeywords(md) + "\",\"" ;

function ListKeywords(md)
{
var varKeywords = "" ;
for (var i = 0; i < md.Keywords.length; ++i) { varKeywords = varKeywords + md.Keywords + ", "; } //strip off final comma and space varKeywords = varKeywords.substring( 0, varKeywords.length-2);
}

return VarPreservedFileName + VarDateTimeOriginal + varLens + varAuthor + vartitle + varOrientation + varRating + varKeywords;

}

==============================
john beardsworth
Community Expert
Community Expert
August 5, 2005
From my original ListMetadata function:
md.namespace = "http://ns.adobe.com/photoshop/1.0/";
varKeywords = ListKeywords(md) + "\",\"" ;

A new function:

function ListKeywords(md)
{
var varKeywords = "" ;
for (var i = 0; i < md.Keywords.length; ++i)
{
varKeywords = varKeywords + md.Keywords + ", ";
}
//strip off final comma and space
varKeywords = varKeywords.substring( 0, varKeywords.length-2);

return varKeywords ;
}
john beardsworth
Community Expert
Community Expert
August 5, 2005
Thanks for posting it Arnold. The keywords will be awkward, as they're going to be a multivalue field. So you'll need to calculate their "length" (count) and use that in a for loop like in the ListMetadata function, converting it into a comma separated string. I'd probably do it as a separate function, called from a line in ListMetadata. Depending on what you ultimately want to do, it may even be easier to export the filename and keywords as a separate file so it can be imported as another table into Access.

Isn't Flash under the exif properties? You may be able to get at it by setting the namespace to http://ns.adobe.com/exif/1.0/Flash/ and then looking for Fired.
Participating Frequently
August 4, 2005
John,

I have been adding to and modifying the script you supplied to me the other day and was able to add 24 fields to the Export file. Below is the updated script I have been working for over 8 hours.

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

#target bridge

if (BridgeTalk.appName == "bridge")
{
// Let's create our menu
var menu = MenuElement.create( "command", "Export File List to Spreadsheet", "at the end of Tools");
menu.onSelect = function(m) {
try
{
// Let's ask what the name of the output file
var f = File.saveDialog("Export file list to:", "Comma delimited file:*.CSV");

// Write the column headings
f.open("w");
f.writeln("Seq Number,New File Name,New File Name Path,Original File Name,Org Dt & Tm,ISO,Exposure Time,F Stop,EV,Exposure Program,Meter Mode,Focal Length,Flash,Lens,Author, Author's Position,City,Country,Description,Title,Orientation,Width,Height,Rating,Label");

// Let's get a list of all the visible thumbnails
var items = app.document.visibleThumbnails;

for (var i = 0; i < items.length; ++i) { var item = items; f.writeln(i + 1, ",\"", item.name, "\",\"", item.path.replace(/\"/g, "\"\""), "\",\"", ListMetadata(item), "\",\"", "\"" ); } f.close(); } catch(e) { } } menu.onDisplay = function(m) { m.enabled = app.document.contentPaneMode == "filesystem" && app.document.visibleThumbnails.length > 0;
}
}

function ListMetadata(tn)
{
md = tn.metadata;
md.namespace = "http://ns.adobe.com/photoshop/1.0/";
varAuthor = md.Author + "\",\"" + md.AuthorsPosition + "\",\"" + md.City + "\",\"" + md.Country + "\",\"";

md.namespace = "http://ns.adobe.com/exif/1.0/aux/";
varLens = md.Lens + "\",\"" ;

md.namespace = "http://purl.org/dc/elements/1.1/";
vartitle = md.title + "\",\"" + md.description + "\",\"" ;

md.namespace = "http://ns.adobe.com/xap/1.0/mm/"
VarPreservedFileName = md.PreservedFileName + "\",\"" ;

md.namespace = "http://ns.adobe.com/exif/1.0/"
VarDateTimeOriginal = md.DateTimeOriginal + "\",\"" + md.ISOSpeedRatings + "\",\"" + md.ExposureTime + "\",\"" + md.FNumber + "\",\"" + md.ExposureBiasValue + "\",\"" + md.ExposureProgram + "\",\"" + md.MeteringMode + "\",\"" + md.FocalLengthIn35mmFilm + "\",\"" + md.Flash + "\",\"" ;

md.namespace = "http://ns.adobe.com/tiff/1.0/"
varOrientation = md.Orientation + "\",\"" + md.ImageWidth + "\",\"" + md.ImageLength + "\",\"" ;

md.namespace = "http://ns.adobe.com/xap/1.0/"
varRating = md.Rating + "\",\"" + md.Label ;

return VarPreservedFileName + VarDateTimeOriginal + varLens + varAuthor + vartitle + varOrientation + varRating;

}

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

I still have 3 files I would like to add to this script but I hit a brick wall. Below are the 3 fields I would like to add this script:

1. File size
2. Did the flash fire?
3. Keywords (I need to take the multiple rows that the bridge stores them in and put them in the same record the other fields are in and separate the keywords by a space or some other character.

All help will be much appreciate. If you can't, maybe you can direct me to somebody who could help me.

Thanks again,

Arnold
john beardsworth
Community Expert
Community Expert
August 3, 2005
Glad it helped Arnold - I hoped posting it "as is" would help you.

John
Participating Frequently
August 3, 2005
John,

Thank you for your script. I was able to figured out how to add the additionals fields to the script you provided me. It took me a while since I am not a programmer.

Thanks again,

Arnold
john beardsworth
Community Expert
Community Expert
August 2, 2005
#target bridge

if (BridgeTalk.appName == "bridge")
{
// Let's create our menu
var menu = MenuElement.create( "command", "Export File List to Spreadsheet", "at the end of Tools");
menu.onSelect = function(m) {
try
{
// Let's ask what the name of the output file
var f = File.saveDialog("Export file list to:", "Comma delimited file:*.CSV");

// Write the column headings
f.open("w");
f.writeln("#,name,path,Author, Country, Location, CountryCode, Lens");

// Let's get a list of all the visible thumbnails
var items = app.document.visibleThumbnails;

for (var i = 0; i < items.length; ++i) { var item = items; f.writeln(i + 1, ",\"", item.name, "\",\"", item.path.replace(/\"/g, "\"\""), "\",\"", ListMetadata(item), "\",\"", "\"" ); } f.close(); } catch(e) { } } menu.onDisplay = function(m) { m.enabled = app.document.contentPaneMode == "filesystem" && app.document.visibleThumbnails.length > 0;
}
}

function ListMetadata(tn)
{
md = tn.metadata;
md.namespace = "http://ns.adobe.com/photoshop/1.0/";
varAuthor = md.Author + "\",\"" + md.Country + "\",\"";

md.namespace = "http://iptc.org/std/Iptc4xmpCore/1.0/xmlns/" ;
varLocation = md.Location + "\",\"" + md.CountryCode + "\",\"" ;

md.namespace = "http://ns.adobe.com/exif/1.0/aux/";
varLens = md.Lens ;

return varAuthor + varLocation + varLens ;

}
Participant
September 22, 2011

hey john  or anyone for that matter can u write me a quick script that just exports the file name and the photo rating for each photo in bridge to csv.. i tried altering an existing script but it never worked.. i would appreciate it if i could name the csv and save it to a specific location but its not too important as beggers cant be choosers and just being able to export both those things to the same location in a csv would be killer thank you in advance.

Paul Riggott
Inspiring
September 22, 2011

There are several scripts that will do.

The first field is always the filename

http://www.scriptsrus.talktalk.net/Extract%20Metadata.htm

There are a couple of scripts here that should as well...

http://www.ps-scripts.com/bb/viewtopic.php?f=19&t=2365&sid=7cbc4e7da597d9e83c6c833fe5cb787a