Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
#target bridge
if( BridgeTalk.appName == "bridge" ) {
addInfo = new MenuElement("command", "Update Entry Details", "at the end of Thumbnail");
}
addInfo .onSelect = function () {
main();
}
function main(){
var csv = File.openDialog("Please select CSV file.","CSV File:*.csv");
if(csv != null){
var errorlog = new File("~/ErrorLog.txt");
errorlog.open('w');
errorlog.writeln("These documents have not been updated");
csv.open("r");
csv.encoding = "UTF-16";
while(!csv.eof){
strInputLine = csv.readln();
if (strInputLine.length > 3) { // Make sure it isn't a blank line
strInputLine = strInputLine.replace(/\\/g,'/'); //Change backslash to forward slash.
inputArray = strInputLine.split(",");
var csvFile = new File(inputArray[0]);
var title = inputArray[1];
var author = inputArray[2];
if(!csvFile.exists) errorlog.writeln(decodeURI(csvFile) + " does not exist");
if(csvFile.exists){ //Check if file exists
item = new Thumbnail(csvFile);
md =item.synchronousMetadata;
var result =addTitleAuthor(md,inputArray[1],inputArray[2]);
if(!result) errorlog.writeln(decodeURI(csvFile) + " Unable to apply template");
}
}
}
}
errorlog.close();
errorlog.execute();
}
function addTitleAuthor(metadata, Title, Author)
{
var strTmpl = "TempTmpl";
var strUser = Folder.userData.absoluteURI;
var filTmpl = new File(strUser + "/Adobe/XMP/Metadata Templates/" + strTmpl + ".xmp");
var fResult = false;
try
{ if (filTmpl.exists)
filTmpl.remove();
fResult = filTmpl.open("w");
if (fResult)
// CS3
{
//CS3
//filTmpl.writeln("<x:xmpmeta xmlns:x=\"adobe:ns:meta/\" x:xmptk=\"Adobe XMP Core 4.1-c037 46.282696, Mon Apr 02 2007 18:36:42 \">");
//CS2
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/\">");
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: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");
filTmpl.remove();
} }
catch(e) {
fResult = false;
}
return fResult;
};
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
#target bridge
if( BridgeTalk.appName == "bridge" ) {
addInfo = MenuElement.create("command", "Update Entry Details", "at the end of Thumbnail");
}
addInfo .onSelect = function () {
mainTitleAuthor();
}
function mainTitleAuthor(){
var csv = File.openDialog("Please select CSV file.","CSV File:*.csv");
if(csv != null){
var errorlog = new File("~/ErrorLog.txt");
errorlog.open('w');
errorlog.writeln("These documents have not been updated");
csv.open("r");
//csv.encoding = "UTF-8";
while(!csv.eof){
strInputLine = csv.readln();
if (strInputLine.length > 3) { // Make sure it isn't a blank line
strInputLine = strInputLine.replace(/\\/g,'/'); //Change backslash to forward slash.
inputArray = strInputLine.split(",");
var csvFile = new File(inputArray[0]);
var title = inputArray[1];
var author = inputArray[2];
//errorlog.writeln("*******Ok can read file" +decodeURI(csvFile) + " - " + inputArray[1]+" - " + inputArray[2]);
if(!csvFile.exists) errorlog.writeln(decodeURI(csvFile) + " does not exist");
if(csvFile.exists){ //Check if file exists
item = new Thumbnail(csvFile);
md =item.synchronousMetadata;
// errorlog.writeln("xxxxxxxFile Exists" +decodeURI(csvFile) +inputArray[1]+" - " + inputArray[2]);
var result =addTitleAuthor(md,inputArray[1],inputArray[2]);
if(!result) errorlog.writeln(decodeURI(csvFile) + " Unable to apply template");
}
}
}
}
errorlog.close();
errorlog.execute();
}
function addTitleAuthor(metadata, Title, Author)
{
var strTmpl = "TempTmpl";
var strUser = Folder.userData.absoluteURI;
var filTmpl = new File(strUser + "/Adobe/XMP/Metadata Templates/" + strTmpl + ".xmp");
var fResult = false;
try
{ if (filTmpl.exists)
filTmpl.remove();
fResult = filTmpl.open("w");
if (fResult)
// CS3
{
//CS3
//filTmpl.writeln("<x:xmpmeta xmlns:x=\"adobe:ns:meta/\" x:xmptk=\"Adobe XMP Core 4.1-c037 46.282696, Mon Apr 02 2007 18:36:42 \">");
//CS2
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/\">");
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: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");
filTmpl.remove();
} }
catch(e) {
fResult = false;
}
return fResult;
};
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
#target bridge
if( BridgeTalk.appName == "bridge" ) {
addInfo = MenuElement.create("command", "Update Entry Details", "at the end of Thumbnail");
}
addInfo .onSelect = function () {
mainTitleAuthor();
}
function mainTitleAuthor(){
var csv = File.openDialog("Please select CSV file.","CSV File:*.csv");
if(csv != null){
var errorlog = new File("~/ErrorLog.txt");
errorlog.open('w');
errorlog.writeln("These documents have not been updated");
csv.open("r");
while(!csv.eof){
strInputLine = csv.readln();
errorlog.writeln("=================================================================");
errorlog.writeln("Line From CSV File: " + strInputLine);
if (strInputLine.length > 3) { // Make sure it isn't a blank line
strInputLine = strInputLine.replace(/\\/g,'/'); //Change backslash to forward slash.
inputArray = strInputLine.split(",");
var csvFile = new File(inputArray[0]);
var title = inputArray[1];
var author = inputArray[2];
errorlog.writeln("Ok can read file Checking if File Exists : " +decodeURI(csvFile));
if(!csvFile.exists) errorlog.writeln(decodeURI(csvFile) + " ****Does Not Exist****");
if(csvFile.exists){ //Check if file exists
item = new Thumbnail(csvFile);
md =item.synchronousMetadata;
errorlog.writeln("File Exists" +decodeURI(csvFile) +inputArray[1]+" - " + inputArray[2]);
var result =addTitleAuthor(md,inputArray[1],inputArray[2]);
if(!result) errorlog.writeln(decodeURI(csvFile) + " Unable to apply template");
errorlog.writeln("Back from creating/apply Template");
}
}
}
}
errorlog.close();
errorlog.execute();
}
function addTitleAuthor(metadata, Title, Author)
{
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){
//CS3
//filTmpl.writeln("<x:xmpmeta xmlns:x=\"adobe:ns:meta/\" x:xmptk=\"Adobe XMP Core 4.1-c037 46.282696, Mon Apr 02 2007 18:36:42 \">");
//CS2
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/\">");
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: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");
//filTmpl.remove();
} }
catch(e) {
alert("There was a problem with the Template");
fResult = false;
}
return fResult;
};
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied