Skip to main content
Participating Frequently
April 23, 2012
Answered

Can you import metadata from an excel database to images (JPG, PSD, TIF) in bulk?

  • April 23, 2012
  • 3 replies
  • 42469 views

I am very new to working with metadata. I have a microsoft excel file with the IPTC Core fields I need for each image file.

(Creator, Headline, Description, Keywords, Title, Job Identifier, Credit Line, Source, Rights Usage Terms, Copyright Status and Copyright Notice)

Is there a way to get the metadata into the files without having to copy from a cell into each metadata field individually?

I am hoping some for sort of script, possibly...

Also, if only ONE of these fields needed updating in all of the files (i.e. Rights Usage Terms) can that be done?

I have Bridge 5.1 (and earlier versions CS3/CS4)

This topic has been closed for replies.
Correct answer Stephen Marsh

Perhaps try tab delimited format instead of comma separated value format.

 

Edit – Paul Riggott originally wrote the following instructions:

 

 

N.B. The first field in the input file MUST be the filename only IE:- CRW_0001.jpg

This script will allow you to choose the fields and order they are in within either your CSV or TEXT file so that you can input your metadata.

Fields available are:-

Keywords 1 - These are Keywords that are in ONE field seperated by semicolons

Keywords 2 - These are Keywords in seperate fields. These must be last in the list/file!

N.B. Only one type of Keywords allowed!

Description - Text, if commas are in this field input file MUST be Tab Delimited!

Headline - Text, if commas are in this field input file MUST be Tab Delimited!

Title - Text, if commas are in this field input file MUST be Tab Delimited!

Instructions - Text, if commas are in this field input file MUST be Tab Delimited!

Date Created - Date IE: 12/24/2001

Location - Text, if commas are in this field input file MUST be Tab Delimited!

City - Text

Country - Text

Rating - This should be numeric 1 to 5

CopyrightInfo - Text, if commas are in this field input file MUST be Tab Delimited!

Author - Text

Label - Text, one of Select, Second, Approved, Review or To Do

There is the option to remove a header line if one exists.

Sub-Folders are supported.

Copyright all documents supported.

An error file is created and shown on completion.

3 replies

Known Participant
November 7, 2018

Hi!

Can we use the exact same script for EPS files? I noticed that in Bridge CC 2019 when we click a EPS we can edit it's metadata (title, description, keywords) directly in Bridge.

Knowing this, would a script be possible to read a CSV and import those fields into a EPS instead of a JPG?

Stephen Marsh
Community Expert
Community Expert
November 7, 2018

Hi!

Can we use the exact same script for EPS files? I noticed that in Bridge CC 2019 when we click a EPS we can edit it's metadata (title, description, keywords) directly in Bridge.

Knowing this, would a script be possible to read a CSV and import those fields into a EPS instead of a JP

Yes, the DIY Metadata script works with a Photoshop EPS file (I have not tested with Illustrator EPS):

And it also works for the VRA tool as well:

Known Participant
November 8, 2018

Ok, in the past I tried DIY Metadata script and I didn't seem to work with illustrator EPS (that is the kind of EPS I am trying to work on). I will give it another try along with VRA panel and will post here if it works with Illustrator EPS. Thanks a lot for the suggestion.

Stephen Marsh
Community Expert
Community Expert
April 14, 2016
Paul Riggott
Inspiring
April 23, 2012

This might be of use...

DIY Metadata.jsx

 

EDIT: the link is there now: DIY Metadata.jsx

Participant
December 9, 2017

Hey Paul, I'm trying to edit your script to fill in the "IPTC Subject Code" and keep getting an error from the log for my added input/variable. I basically used other fields as an example to edit the code. I can get your predefined fields to work when using a csv for the input, but can't get my own added IPTC Subject Code to to write. Please help 

Participating Frequently
February 9, 2019

Here is the revised code, also added a bit of error checking this time.

Could you please test this now.

#target bridge  

if( BridgeTalk.appName == "bridge" ) { 

var drone = new MenuElement( "command", "Drone Metadata", "at the end of Tools" );

}

drone.onSelect = function () {

var csvFile = File.openDialog("Open Comma-delimited File","comma-delimited(*.csv):*.csv;");

if (!csvFile.exists) return;

     csvFile.open('r');

     var data = csvFile.read().split("\n");

    csvFile.close();

    var line = new Array();

    for(var a in data){

        var Q = data.toString();

        if(Q.length > 2) line.push(Q);

        }

for(var z in line){

var p=line.split(',');

droneMetadata(trim(p[0]),trim(p[1]),trim(p[2]),trim(p[3]),trim(p[4]));

}

alert("Batch complete\nDrone Error Log on Desktop\n If any errors occured");

function trim(s){

    return s.replace(/^\s+|\s+$/g,'');

    }

function log(message){

var errorLog = File(Folder.desktop + "/Drone Error Log.txt");

errorLog.open("a");

errorLog.writeln(message);

errorLog.close();

   }

function droneMetadata(th,Flag,Lon,Lat,Hgt){

var file = new File(new Folder(app.document.presentationPath)+ '/' + trim(th));

if(!file.exists){

    log("File does not exist! " + trim(th));

    return;

    }

var thumb = new Thumbnail(file);

md = thumb.synchronousMetadata;

if(thumb.hasMetadata){

md.namespace = "http://www.dji.com/drone-dji/1.0/";

md.RtkFlag = '';

md.RtkFlag =  Flag;

md.RtkStdLon = '';

md.RtkStdLon = Lon;

md.RtkStdLat = '';

md.RtkStdLat = Lat;

md.RtkStdHgt = '';

md.RtkStdHgt = Hgt;

}else{

    log("Cannot write metadata to " + decodeURI(thumb.spec));

    }

};

};


SuperMerlin

Good afternoon.  I tried to mod this code myself and I am having trouble.  I found out that I need to also update the GPS data for the EXIF block as well as the XMP block.    I looked to see if I made a typo and do not see one.  I don't know if I have to do something different for two different namespaces.  Would you mind looking at my edits and see if you see my error?

Line changes

03. Changed name in Line 3 (added V2 to give me second menu option)

18. Added trim(p[8]),trim(p[9]),trim(p[10])

30. Added ExLat,ExLon,ExAlt to reference new fields (Exif Latitude, Exif Longitude, Exif Altitude

54-60 Added Adobe Namespace reference and additional fields.  I have GPS all caps as that is how they are in the existing Exif Data.

When I run this in Bridge, it just sits there for 1-2 seconds and then Bridge closes. 


#target bridge  

if( BridgeTalk.appName == "bridge" ) { 

var drone = new MenuElement( "command", "Drone Metadata V2", "at the end of Tools" );

}

drone.onSelect = function () {

var csvFile = File.openDialog("Open Comma-delimited File","comma-delimited(*.csv):*.csv;");

if (!csvFile.exists) return;

     csvFile.open('r');

     var data = csvFile.read().split("\n");

    csvFile.close();

    var line = new Array();

    for(var a in data){

        var Q = data.toString();

        if(Q.length > 2) line.push(Q);

        }

for(var z in line){

var p=line.split(',');

droneMetadata(trim(p[0]),trim(p[1]),trim(p[2]),trim(p[3]),trim(p[4]),trim(p[5]),trim(p[6]),trim(p[7]),trim(p[8]),trim(p[9]),trim(p[10]));

}

alert("Batch complete\nDrone Error Log on Desktop\n If any errors occured");

function trim(s){

    return s.replace(/^\s+|\s+$/,'');

    }

function log(message){

var errorLog = File(Folder.desktop + "/Drone Error Log.txt");

errorLog.open("a");

errorLog.writeln(message);

errorLog.close();

   }

function droneMetadata(th,Flag,StdLon,StdLat,StdHgt,Lat,Lon,Hgt,ExLat,ExLon,ExAlt){

var file = new File(new Folder(app.document.presentationPath)+ '/' + trim(th));

if(!file.exists){

    log("File does not exist! " + trim(th));

    return;

    }

var thumb = new Thumbnail(file);

md = thumb.synchronousMetadata;

if(thumb.hasMetadata){

md.namespace = "http://www.dji.com/drone-dji/1.0/";

md.RtkFlag = '';

md.RtkFlag =  Flag;

md.RtkStdLon = '';

md.RtkStdLon = StdLon;

md.RtkStdLat = '';

md.RtkStdLat = StdLat;

md.RtkStdHgt = '';

md.RtkStdHgt = StdHgt;

md.GpsLatitude = '';

md.GpsLatitude = Lat;

md.GpsLongitude = '';

md.GpsLongitude = Lon;

md.AbsoluteAltitude = '';

md.AbsoluteAltitude = Hgt;

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

md.GPSLatitude = '';

md.GPSLatitude =  ExLat;

md.GPSLongitude = '';

md.GPSLongitude =  ExLon;

md.GPSAltitude = '';

md.GPSAltitude =  ExAlt;

}else{

    log("Cannot write metadata to " + decodeURI(thumb.spec));

    }

};

};

First Lines of CSV file

DJI_0002.JPG,50,0.008,0.007,0.017,34.95187873,-89.93024736,+148.931,34.95187873,-89.93024736,+148.931

DJI_0003.JPG,50,0.008,0.007,0.017,34.95181193,-89.93017817,+149.19,34.95181193,-89.93017817,+149.19

DJI_0004.JPG,50,0.008,0.011,0.015,34.95176096,-89.93012334,+149.67,34.95176096,-89.93012334,+149.67

DJI_0005.JPG,50,0.008,0.006,0.015,34.95170888,-89.93005634,+149.769,34.95170888,-89.93005634,+149.769

DJI_0006.JPG,50,0.008,0.006,0.015,34.95165501,-89.92998616,+149.653,34.95165501,-89.92998616,+149.653

DJI_0007.JPG,50,0.008,0.007,0.016,34.95154082,-89.92984514,+149.955,34.95154082,-89.92984514,+149.955

DJI_0008.JPG,50,0.012,0.019,0.016,34.95148343,-89.92977355,+150.012,34.95148343,-89.92977355,+150.012

DJI_0009.JPG,50,0.008,0.007,0.016,34.95142627,-89.92969896,+149.788,34.95142627,-89.92969896,+149.788

DJI_0010.JPG,50,0.008,0.007,0.016,34.95136721,-89.92962243,+149.572,34.95136721,-89.92962243,+149.572

DJI_0011.JPG,50,0.008,0.006,0.015,34.95130963,-89.92954778,+149.635,34.95130963,-89.92954778,+149.635

DJI_0012.JPG,50,0.008,0.007,0.017,34.95126481,-89.92948684,+149.564,34.95126481,-89.92948684,+149.564