Copy link to clipboard
Copied
Hello together,
i need your help to append my title with a word "webshop".
example:
current title:
car 01
new tittle:
car 01 webshop
I have the code but it doesn't work:
#target bridge
if( BridgeTalk.appName == "bridge" ) {
FT = MenuElement.create("command", "Add Webshop to Title", "at the end of Tools");
}
FT.onSelect = function () {
AddWebshopToTitle();
}
function AddWebshopToTitle(){
var thumbs = app.document.selections;
if(!thumbs.length) return;
if (ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new
ExternalObject("lib:AdobeXMPScript");
for(var a in thumbs){
var selectedFile = thumbs[a].spec;
/*var Title = decodeURI(selectedFile.name).replace(/\.[^\.]+$/, '')//([0-9/[-].jpg/]*) nur name*/
var webshop = "Webshop"
var myXmpFile = new XMPFile( selectedFile.fsName, XMPConst.UNKNOWN,
XMPConst.OPEN_FOR_UPDATE);
var myXmp = myXmpFile.getXMP();
/*myXmp.deleteProperty(XMPConst.NS_DC, "title");*/
myXmp.appendArrayItem(XMPConst.NS_DC, "title", webshop, 0,
XMPConst.ALIAS_TO_ALT_TEXT);
myXmp.setQualifier(XMPConst.NS_DC, "title[1]",
"http://www.w3.org/XML/1998/namespace", "lang", "x-default");
if (myXmpFile.canPutXMP(myXmp)) {
myXmpFile.putXMP(myXmp);
myXmpFile.closeFile(XMPConst.CLOSE_UPDATE_SAFELY);
}
}
}
Thank you
I can't find where this script came from, I'm guessing Paul Riggott.
I made some cosmetic changes to the GUI for modern versions of Bridge.
#target bridge
if (BridgeTalk.appName == "bridge") {
ReplaceTitle = new MenuElement("command", "Find and Replace in Title", "at the end of tools");
}
ReplaceTitle.onSelect = function () {
var win = new Window('dialog', 'Find & Replace in Title');
g = win.graphics;
var myBrush = g.newBrush(g.BrushType.SOLID_COLOR, [0.2, 0.2, 0.2, 1]);
...
Copy link to clipboard
Copied
I found a solution
#target bridge
if( BridgeTalk.appName == "bridge" ) {
FT = MenuElement.create("command", "Testing", "at the end of Tools");
}
FT.onSelect = function () {
var thumbs = app.document.selections;
if(!thumbs.length) return;
if (ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");
for(var a in thumbs){
var selectedFile = thumbs[a].spec;
/*var FileName = decodeURI(selectedFile.name).slice(0,7);*/
var TitleName = decodeURI(selectedFile.title);
var webshop = "Colour Swatch Webshop"
var myXmpFile = new XMPFile( selectedFile.fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_UPDATE);
var myXmp = myXmpFile.getXMP();
var Desc=[];
var count = myXmp.countArrayItems(XMPConst.NS_DC, "title");
for(var i = 1;i <= count;i++){
Desc.push(myXmp.getArrayItem(XMPConst.NS_DC, "title", i));
}
Desc=Desc.toString() + " " + webshop;
myXmp.deleteProperty(XMPConst.NS_DC, "title");
myXmp.appendArrayItem(XMPConst.NS_DC, "title", Desc, 0, XMPConst.ALIAS_TO_ALT_TEXT);
myXmp.setQualifier(XMPConst.NS_DC, "title[1]", "http://www.w3.org/XML/1998/namespace", "lang", "x-default");
if (myXmpFile.canPutXMP(myXmp)) {
myXmpFile.putXMP(myXmp);
myXmpFile.closeFile(XMPConst.CLOSE_UPDATE_SAFELY);
}
}
}
Copy link to clipboard
Copied
Now I want to copy the title field behind the semicolon like:
car webshop; car webshop
here my code, but doesn't work:
#target bridge
if( BridgeTalk.appName == "bridge" ) {
FT = MenuElement.create("command", "Testing1", "at the end of Tools");
}
FT.onSelect = function () {
var thumbs = app.document.selections;
if(!thumbs.length) return;
if (ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");
for(var a in thumbs){
var selectedFile = thumbs[a].spec;
/*var FileName = decodeURI(selectedFile.name).slice(0,7);*/
var TitleName = decodeURI(selectedFile.title);
var webshop = ";"
var myXmpFile = new XMPFile( selectedFile.fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_UPDATE);
var myXmp = myXmpFile.getXMP();
var Desc=[];
var count = myXmp.countArrayItems(XMPConst.NS_DC, "title");
for(var i = 1;i <= count;i++){
Desc.push(myXmp.getArrayItem(XMPConst.NS_DC, "title", i));
}
Desc=Desc.toString() + " " + webshop + " " + TitleName;
myXmp.deleteProperty(XMPConst.NS_DC, "title");
myXmp.appendArrayItem(XMPConst.NS_DC, "title", Desc, 0, XMPConst.ALIAS_TO_ALT_TEXT);
myXmp.setQualifier(XMPConst.NS_DC, "title[1]", "http://www.w3.org/XML/1998/namespace", "lang", "x-default");
if (myXmpFile.canPutXMP(myXmp)) {
myXmpFile.putXMP(myXmp);
myXmpFile.closeFile(XMPConst.CLOSE_UPDATE_SAFELY);
}
}
}
Copy link to clipboard
Copied
I don't think selectedFile.title will read the current title field, if that's what you are tyring to do.
You are doing a lot of changes with multiple scripts. Maybe it would be better to export the metadata to a spreadsheet, fix everything once, then import it back to the images and be finished.
Copy link to clipboard
Copied
How can i transfer it to a spreadsheet, do have a snippet of script?
Copy link to clipboard
Copied
ExifTool is good for this, but it's command line and requires a little more work.
You can try this: Adobe Bridge User Customizable Export-Import
Copy link to clipboard
Copied
Copy link to clipboard
Copied
I can't find where this script came from, I'm guessing Paul Riggott.
I made some cosmetic changes to the GUI for modern versions of Bridge.
#target bridge
if (BridgeTalk.appName == "bridge") {
ReplaceTitle = new MenuElement("command", "Find and Replace in Title", "at the end of tools");
}
ReplaceTitle.onSelect = function () {
var win = new Window('dialog', 'Find & Replace in Title');
g = win.graphics;
var myBrush = g.newBrush(g.BrushType.SOLID_COLOR, [0.2, 0.2, 0.2, 1]);
g.backgroundColor = myBrush;
win.orientation = 'column';
win.p1 = win.add("panel", undefined, undefined, { borderStyle: "black" });
win.p1.preferredSize = [380, 100];
win.g1 = win.p1.add('group');
win.g1.orientation = "row";
win.title = win.g1.add('statictext', undefined, 'Title Editor');
win.title.alignment = "fill";
var g = win.title.graphics;
g.font = ScriptUI.newFont("Arial", "BOLD", 22);
win.p6 = win.p1.add("panel", undefined, undefined, { borderStyle: "black" }); //Replace
win.p6.preferredSize = [380, 100];
win.g600 = win.p6.add('group');
win.g600.orientation = "row";
win.g600.alignment = 'fill';
win.g600.st1 = win.g600.add('statictext', undefined, 'Replace');
win.g600.st1.preferredSize = [75, 20];
win.g600.et1 = win.g600.add('edittext');
win.g600.et1.preferredSize = [200, 20];
win.g610 = win.p6.add('group');
win.g610.orientation = "row";
win.g610.alignment = 'fill';
win.g610.st1 = win.g610.add('statictext', undefined, 'With');
win.g610.st1.helpTip = "Leave this field blank if you want to remove the characters";
win.g610.st1.preferredSize = [75, 20];
win.g610.et1 = win.g610.add('edittext');
win.g610.et1.preferredSize = [200, 20];
win.g620 = win.p6.add('group');
win.g620.orientation = "row";
win.g620.alignment = 'fill';
win.g620.cb1 = win.g620.add('checkbox', undefined, 'Global');
win.g620.cb1.helpTip = "Replace all occurrences of";
win.g620.cb2 = win.g620.add('checkbox', undefined, 'Case Insensitive');
win.g620.cb2.value = true;
win.g1000 = win.p1.add('group');
win.g1000.orientation = "row";
win.g1000.alignment = 'center';
win.g1000.bu1 = win.g1000.add('button', undefined, 'Process');
win.g1000.bu1.preferredSize = [170, 30];
win.g1000.bu2 = win.g1000.add('button', undefined, 'Cancel');
win.g1000.bu2.preferredSize = [170, 30];
win.g1000.bu1.onClick = function () {
if (win.g600.et1.text == '') {
alert("No replace value has been entered!");
return;
}
win.close(0);
var sels = app.document.selections;
for (var a in sels) {
var thumb = sels[a];
md = thumb.synchronousMetadata;
if (win.g620.cb1.value && !win.g620.cb2.value) var patt = new RegExp(win.g600.et1.text.toString(), "g");
if (!win.g620.cb1.value && win.g620.cb2.value) var patt = new RegExp(win.g600.et1.text.toString(), "i");
if (win.g620.cb1.value && win.g620.cb2.value) var patt = new RegExp(win.g600.et1.text.toString(), "gi");
if (!win.g620.cb1.value && !win.g620.cb2.value) var patt = new RegExp(win.g600.et1.text.toString());
md.namespace = "http://purl.org/dc/elements/1.1/";
var Caption = md.title ? md.title[0] : "";
if (Caption == "") continue;
var result = patt.test(Caption.toString());
if (result == true) {
var newCaption = Caption.replace(patt, win.g610.et1.text.toString());
setTitle(sels[a].spec, newCaption);
}
}
}
win.show();
function setTitle(file, Caption) {
if (!ExternalObject.AdobeXMPScript) ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript');
var xmpf = new XMPFile(File(file).fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_UPDATE);
var xmp = xmpf.getXMP();
xmp.deleteProperty(XMPConst.NS_DC, "title");
xmp.setLocalizedText(XMPConst.NS_DC, "title", null, "x-default", Caption);
if (xmpf.canPutXMP(xmp)) {
xmpf.putXMP(xmp);
}
xmpf.closeFile(XMPConst.CLOSE_UPDATE_SAFELY);
}
};
Regular Expression Based Find:
$
Replace:
; webshop
Copy link to clipboard
Copied
So @Jörn5F90 – where did you end up?
Copy link to clipboard
Copied
Hello together,
i need your help
i have this titel
"car blue; Auto blau"
How can I add webshop to title before and after the semicolon like this
"car blue webshop; Auto blau webshop"
Thanks, Jörn
Copy link to clipboard
Copied
Hi,
Could you please provide more information on what is the issue and how can we reproduce it on our end?
Can you please share the Bridge Version as well?
Thanks,
Bridge Team
Copy link to clipboard
Copied
You would need to write a script that read the Title field, used a regular expression to add your text, and wrote it back out. This might be easier with exiftool instead of Bridge.
Copy link to clipboard
Copied
Using the previous "Title Editor" script, you can use the following regular expression find/replace:
Find:
(^.+)(;)(.+)
Replace:
$1 webshop;$3 webshop
or if you want space after the semi-colon
$1 webshop; $3 webshop
This assumes that the "quote marks" don't actually exist in the title and that there are only two entries, separated by a semi-colon.
Copy link to clipboard
Copied
Thank you it works
Copy link to clipboard
Copied
Please log-in and mark it as a correct answer if this works.