Copy link to clipboard
Copied
Copy link to clipboard
Copied
Hi Paul,
Thanks for the great scripts. I can use this and your import kewords script to automate quite a bit of data entry.
How can the metadata import fields be changed? I would like to be able to import data into a couple more fields but don't know much about scripts.
I am guessing things need to change around here
var titleAuthor= strInputLine.substr(strInputLine.indexOf(",")+1);
titleAuthor = titleAuthor.replace(/&/g,"&");
inputArray = strInputLine.split(",");
inputArray2 = titleAuthor.split(",");
var csvFile = new File(inputArray[0]);
var title = inputArray2[0];
var author = inputArray2[1];
var Country = inputArray2[2];
to add to the description field.
Thanks.
Joe
Copy link to clipboard
Copied
It's a long time since I looked at this but think this is the code with the Description field added for you..
#target bridge
if( BridgeTalk.appName == "bridge" ) {
addInfo = MenuElement.create("command", "Add CSV Information", "at the end of Thumbnail");
}
addInfo .onSelect = function () {
TitleAuthorCountryDesc();
}function TitleAuthorCountryDesc(){
var value = 0;
var win = new Window("palette{text:'Please wait...',bounds:[100,100,550,140]," +
"progress:Progressbar{bounds:[20,10,430,28] , minvalue:0,value:" + value + "}" +
"};"
);
var csv = File.openDialog("Please select CSV file.","CSV File:*.csv");
csv.encoding = "UTF-8";
if(csv != null){
csv.open("r");
var csvtemp=csv.read();
csvtemp =csvtemp.split("\n");
var maxcount = csvtemp.length;
csv.close();
csv.open("r");
win.progress.maxvalue =maxcount;
while(!csv.eof){
win.center();
win.show();
win.hide();
win.show();
win.progress.value++;
strInputLine = csv.readln();
if (strInputLine.length > 3) {
strInputLine = strInputLine.replace(/\\/g,'/');
var titleAuthor= strInputLine.substr(strInputLine.indexOf(",")+1);
titleAuthor = titleAuthor.replace(/&/g,"&");
inputArray = strInputLine.split(",");
inputArray2 = titleAuthor.split(",");
var csvFile = new File(inputArray[0]);
var title = inputArray2[0];
var author = inputArray2[1];
var Country = inputArray2[2];
var Description = inputArray2[3];
if(csvFile.exists){
item = new Thumbnail(csvFile);
md =item.synchronousMetadata;
var result =addTitleAuthor(md,inputArray2[0],inputArray2[1],inputArray2[2],inputArray2[3]);
}
}
}
}
win.close(2);
errorlog.close();
errorlog.execute();
}function addTitleAuthor(metadata, Title, Author,Country,Description) {
var strTmpl = "TempTmpl";
var strUser = Folder.userData.absoluteURI;
var filTmpl = new File(strUser + "/Adobe/XMP/Metadata Templates/" + strTmpl + ".xmp");
var fResult = false;if (filTmpl.exists) filTmpl.remove();
try{
fResult = filTmpl.open("w");
}catch(e){
alert("Unable to create Template " +filTmpl +"\r"+e.message);
return;
}
try{
if (fResult){
filTmpl.writeln("<x:xmpmeta xmlns:x=\"adobe:ns:meta/\" x:xmptk=\"3.1.2-113\">");
filTmpl.writeln("<rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">");
filTmpl.writeln("<rdf:Description rdf:about=\"\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:photoshop=\"http://ns.adobe.com/photoshop/1.0/\" photoshop:Country=\""+Country +"\">");
filTmpl.writeln("<dc:title>");
filTmpl.writeln("<rdf:Alt>");
filTmpl.writeln("<rdf:li xml:lang=\"x-default\">"+Title+"</rdf:li>");
filTmpl.writeln("</rdf:Alt>");
filTmpl.writeln("</dc:title>");
filTmpl.writeln("<dc:description>");
filTmpl.writeln("<rdf:Alt>");
filTmpl.writeln("<rdf:li xml:lang='x-default'>"+Description+"</rdf:li>");
filTmpl.writeln("</rdf:Alt>");
filTmpl.writeln("</dc:description>");
filTmpl.writeln("<dc:creator>");
filTmpl.writeln("<rdf:Seq>");
filTmpl.writeln("<rdf:li>" + Author + "</rdf:li>");
filTmpl.writeln("</rdf:Seq>");
filTmpl.writeln("</dc:creator>");
filTmpl.writeln("</rdf:Description>");
filTmpl.writeln("</rdf:RDF>");
filTmpl.writeln("</x:xmpmeta>");
fResult = filTmpl.close();
metadata.applyMetadataTemplate(strTmpl, "replace");
} }
catch(e) {
alert("There was a problem with the Template");
fResult = false;
}
return fResult;
};
Copy link to clipboard
Copied
The script works great!
Seeing the differences between the scripts helps me see how they operate.
Thanks for the quick response.
Joe
Copy link to clipboard
Copied
The easy way to see what to change in the template section of the script is to create a new template in Bridge with the fields you require and look at the xmp file it creates.
Paul.
Copy link to clipboard
Copied
Good idea. I'll try it out next week.
Joe