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){
csv.open("r");
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){ //Check if file exists
writeMetadata(inputArray[0],inputArray[1],inputArray[2]);
}
}
}
}
}
function writeMetadata(file,title,author){
item = new Thumbnail(file);
md =item.synchronousMetadata;
md.namespace = "http://purl.org/dc/elements/1.1/"
md.title = title;
md.namespace = "http://ns.adobe.com/photoshop/1.0/";
md.Author = author;
}
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 = 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){
loadXMPScript();
csv.open("r");
while(!csv.eof){
strInputLine = csv.readln();
if (strInputLine.length > 3) {
strInputLine = strInputLine.replace(/\\/g,'/');
inputArray = strInputLine.split(",");
var csvFile = new File(inputArray[0]);
var title = inputArray[1];
var author = inputArray[2];
if(csvFile.exists){
var file = new Thumbnail(csvFile);
var xmpFile = new XMPFile(file.path, XMPConst.UNKNOWN,XMPConst.OPEN_FOR_UPDATE);
var xmp = xmpFile.getXMP();
xmp.deleteProperty(XMPConst.NS_DC, "creator");
xmp.deleteProperty(XMPConst.NS_DC, "title");
xmp.appendArrayItem(XMPConst.NS_DC, "creator", author, 0,XMPConst.ARRAY_IS_ORDERED);
xmp.appendArrayItem(XMPConst.NS_DC, "title", title, 0,XMPConst.ARRAY_IS_ORDERED);
if (xmpFile.canPutXMP(xmp)) {
xmpFile.putXMP(xmp);
}
xmpFile.closeFile(XMPConst.CLOSE_UPDATE_SAFELY);
}}}
}
}
unloadXMPScript();
function loadXMPScript()
{
var results = new XMPLibMsg("XMPScript Library already loaded", 0, false);
if (!ExternalObject.AdobeXMPScript)
{
try
{
ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript');
results.message = "XMPScript Library loaded";
}
catch (e)
{
results.message = "ERROR Loading AdobeXMPScript: " + e;
results.line = e.line;
results.error = true;
}
}
return results;
}
function unloadXMPScript()
{
var results = new XMPLibMsg("XMPScript Library not loaded", 0, false);
if( ExternalObject.AdobeXMPScript )
{
try
{
ExternalObject.AdobeXMPScript.unload();
ExternalObject.AdobeXMPScript = undefined;
results.message = "XMPScript Library successfully unloaded";
}
catch (e)
{
results.message = "ERROR unloading AdobeXMPScript: " + e;
results.line = e.line;
results.error = true;
}
}
return results;
}
function XMPLibMsg (inMessage, inLine, inError)
{
this.message = inMessage;
this.line = inLine;
this.error = inError;
}
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){
loadXMPScript();
csv.open("r");
while(!csv.eof){
strInputLine = csv.readln();
if (strInputLine.length > 3) {
strInputLine = strInputLine.replace(/\\/g,'/');
inputArray = strInputLine.split(",");
var csvFile = new File(inputArray[0]);
var title = inputArray[1];
var author = inputArray[2];
/////////////////////////////////////////////////////////////////////////////////////////////////
if(!csvFile.exists) alert(csvFile + " Does not exist"); //////////Check if file exists
//////////////////////////////////////////////////////////////////////////////////////////////////
if(csvFile.exists){
var file = new Thumbnail(csvFile);
var xmpFile = new XMPFile(file.path, XMPConst.UNKNOWN,XMPConst.OPEN_FOR_UPDATE);
var xmp = xmpFile.getXMP();
xmp.deleteProperty(XMPConst.NS_DC, "creator");
xmp.deleteProperty(XMPConst.NS_DC, "title");
xmp.appendArrayItem(XMPConst.NS_DC, "creator", author, 0,XMPConst.ARRAY_IS_ORDERED);
xmp.appendArrayItem(XMPConst.NS_DC, "title", title, 0,XMPConst.ARRAY_IS_ORDERED);
if (xmpFile.canPutXMP(xmp)) {
xmpFile.putXMP(xmp);
}
xmpFile.closeFile(XMPConst.CLOSE_UPDATE_SAFELY);
}
}
}
}
}
unloadXMPScript();
function loadXMPScript()
{
var results = new XMPLibMsg("XMPScript Library already loaded", 0, false);
if (!ExternalObject.AdobeXMPScript)
{
try
{
ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript');
results.message = "XMPScript Library loaded";
}
catch (e)
{
results.message = "ERROR Loading AdobeXMPScript: " + e;
results.line = e.line;
results.error = true;
}
}
return results;
}
function unloadXMPScript()
{
var results = new XMPLibMsg("XMPScript Library not loaded", 0, false);
if( ExternalObject.AdobeXMPScript )
{
try
{
ExternalObject.AdobeXMPScript.unload();
ExternalObject.AdobeXMPScript = undefined;
results.message = "XMPScript Library successfully unloaded";
}
catch (e)
{
results.message = "ERROR unloading AdobeXMPScript: " + e;
results.line = e.line;
results.error = true;
}
}
return results;
}
function XMPLibMsg (inMessage, inLine, inError)
{
this.message = inMessage;
this.line = inLine;
this.error = inError;
}
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
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied