Copy link to clipboard
Copied
Hi all,
I'd like to copy filename to keywords. I've read this forum but I can't find a solution to my case.. So if someone could help me and tell me how to do that I'll be very happy. I don't have any javascript skills, so if someone would push me forward, that'll be nice.
I'm using Bridge CS3, MacOS 10.5.8. I'd like to use it with Automator, or if someone has better solution, please let me know.
Thanks,
Pete
This will put the filename only no extension..
#target bridge
addNametoMeta = {};
addNametoMeta.execute = function(){
var sels = app.document.selections;
for (var i = 0; i < sels.length; i++){
var md = sels.synchronousMetadata;
md.namespace = "http://ns.adobe.com/photoshop/1.0/";
var Name = decodeURI(sels.name).replace(/\.[^\.]+$/, '');
md.Keywords = md.Keywords + ";" + Name;
}
}
if (BridgeTalk.appName == "bridge"){
var menu = MenuElement.create( "command", "Save Filename in Keyw
...
Copy link to clipboard
Copied
Thanks Kukurykus I did not realise that this was cross posted into two different forums and topic threads! Sigh…
Anyway, I’m happy that this particular topic thread gave me a chance to practice hacking/editing a different script to achieve the same end result.
Copy link to clipboard
Copied
Hi all,
I have a client looking to turn thousands of photos' descriptions into keywords. I've looked through the forums but couldn't find an answer to my problem. The script needs to turn the description field in my metadata to individual keywords. Each space in between the words would need to be turned into a comma so bridge can read each word in my description as as separate keyword. Does anyone have a script like this?
Copy link to clipboard
Copied
See my reply and solution here:
Copy link to clipboard
Copied
This can also be performed using ExifTool, removing the file extension and replacing any existing keywords:
exiftool -r '-Subject<${filename;s/\..*?$//}' 'PATH-to-FILE-or-FOLDER'
Or, to append to existing keywords while removing the file extension:
exiftool -r '-Subject+<${filename;s/\..*?$//}' 'PATH-to-FILE-or-FOLDER'
Copy link to clipboard
Copied
Hi Paul,
as it seems you´re the godfather of scripting ... and now I need your help.
I´m working on CS4, Windows XP and I have more than 1500 folders in Bridge containing up to 15 pictures to handle.
I want the name of the folder written in one of the iptc fields, doesn´t matter if it´s the keyword or description. Unfortunately, in some of the pictures these fields are already filled out, so I want to add the foldername.
Due to the fact that I don´t know how to handle java and how to save it, I really appreciate your help.
Edit: I finally got it working, but now I have the problem that the folder contains other folders in which are the pictures ...
Example:
Folder XY
Just the folders "other name" are filled with pictures but I need the "Folder XY" written in the IPTC-fields.
Can you help ?
Kind regards and thanks a lot !
Alex
Copy link to clipboard
Copied
If you want the Parent folder name you can use this..
#target bridge
addFolderNametoMeta = {};
addFolderNametoMeta.execute = function(){
var sels = app.document.selections;
for (var i = 0; i < sels.length; i++){
var md = sels.synchronousMetadata;
md.namespace = "http://ns.adobe.com/photoshop/1.0/";
md.Keywords = md.Keywords + ";" + decodeURI(sels.spec.parent.parent.name);
}
}
if (BridgeTalk.appName == "bridge"){
var menu = MenuElement.create( "command", "Save FolderName in Keywords", "at the end of Tools");
menu.onSelect = addFolderNametoMeta.execute;
}
Or if you want to do ALL subfolders this might do..
You need to be in the top level folder.
This also removes duplicates in the keyword field.
Amend the folder name to suit....
#target bridge
if( BridgeTalk.appName == "bridge" ) {
AddFolderNameToMeta = MenuElement.create("command", "Add FolderName to Files", "at the end of Tools");
}
AddFolderNameToMeta.onSelect = function () {
addFolderName();
}
function addFolderName(){
var folders =[];
var Pics=0;
folders = FindAllFolders(Folder(app.document.presentationPath), folders);
folders.unshift(Folder(app.document.presentationPath));
for(var a in folders){
var PictureFiles = folders.getFiles(/\.(jpg|jpe|jpeg|gif|eps|dng|bmp|tif|tiff|psd|rle|dib|cin|dpx|sct|pbm|flm|psb|exr|pcx|pdp|...
)
Pics++;
}
}
alert("Number of Folders Processed = "+folders.length+ " Documents Processed = "+Pics);
function addKeyword(fileName){
if (ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");
var thumb = new Thumbnail(fileName);
var folderName = decodeURI(fileName.parent.name);
//Or if you want the folders Parent use the line below.
//var folderName = decodeURI(fileName.parent.parent.name);
if(thumb.hasMetadata){
var selectedFile = thumb.spec;
try{
var myXmpFile = new XMPFile( selectedFile.fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_UPDATE);
var myXmp = myXmpFile.getXMP();
var keys = getArrayItems(XMPConst.NS_DC,'subject');
keys.unshift(folderName);
keys= ReturnUniqueSortedList(keys);
myXmp.deleteProperty(XMPConst.NS_DC,'subject');
for(var z in keys){
myXmp.appendArrayItem(XMPConst.NS_DC, "subject", keys, 0,XMPConst.PROP_IS_ARRAY);
}
}catch(e){}
if (myXmpFile.canPutXMP(myXmp)) {
myXmpFile.putXMP(myXmp);
myXmpFile.closeFile(XMPConst.CLOSE_UPDATE_SAFELY);
}
}
function getArrayItems(ns, prop){
var arrItem=[];
var items = myXmp.countArrayItems(ns, prop);
for(var i = 1;i <= items;i++){
arrItem.push(myXmp.getArrayItem(ns, prop, i));
}
return arrItem;
}
};
function FindAllFolders( srcFolderStr, destArray) {
var fileFolderArray = Folder( srcFolderStr ).getFiles();
for ( var i = 0; i < fileFolderArray.length; i++ ) {
var fileFoldObj = fileFolderArray;
if ( fileFoldObj instanceof File ) {
} else {
destArray.push( Folder(fileFoldObj) );
FindAllFolders( fileFoldObj.toString(), destArray );
}
}
return destArray;
}
function ReturnUniqueSortedList(ArrayName){
var unduped = new Object;
for (var i = 0; i < ArrayName.length; i++) {
unduped[ArrayName] = ArrayName;
}
var uniques = new Array;for (var k in unduped) {
uniques.push(unduped);
}
uniques.sort();
return uniques;
}
};
Copy link to clipboard
Copied
Good morning, Paul and thanks so much for your help.
Unfortunately, both scripts won´t work the way I wanted it - either I´m doing something wrong or my description of the way the script should work was too complicated.
First of all, I describe you what I did:
I marked the parent folder in Bridge without showing the assets in the subfolders, then start the script. The first (short) script has no effect at all, the second (long) script is working, the message pops up and tells me, what the script did. But: The second script puts the name of the subfolders in IPTC but not the name of the parent folder.
At the screenshot you can see an example how the structure is and what I´m looking for.
The name of the folder "This folder name in IPTC" (the parent folder) is the information I want to be written in the IPTC-information of the pictures in Subfolder_01
Is this possible too ? Or did I something wrong ?
Thanks a lot once again,
Alex
Copy link to clipboard
Copied
Guys, it makes me think that a script such as this could also solve the nagging problem "There was an error writing metadata" in Bridge.
For instance, if you wanted to classify certain Description fields to all carry the same comment, could that be done by using the string of words in the script and direct it to populate that field?
Copy link to clipboard
Copied
Guys, it makes me think that a script such as this could also solve the nagging problem "There was an error writing metadata" in Bridge.
For instance, if you wanted to classify certain Description fields to all carry the same comment, could that be done by using the string of words in the script and direct it to populate that field?
This is what a metadata template is for.
Tools > Create Metadata Template…
Tools > Apply Metadata Template…
Or you could just select multiple files and manually enter into the Bridge metadata panel.
However it could be done with a script or ExifTool. As for the error, I have seen some files that needed to be re-saved in order for them to accept metadata, there was some minor corruption in the file that was blocking the writing of metadata.
Copy link to clipboard
Copied
Tagging onto an older conversation. I am trying to add a script copy my filenames to IPTC Keywords without the file extension in Bridge ver12. I have tried three different scripts from these older discussion chains and none seem to be working. I did add the Utlity Script Pack and the script to move File Name to the IPTC Title and it is working.
Copy link to clipboard
Copied
These scripts are ripped of characters like [i] due to transition to new forums platform.
Copy link to clipboard
Copied
Thanks, I will trying a new post in the Bridge Forum
Copy link to clipboard
Copied
I replied in the other forum post. BTW I'm the author of the Script Utility Pack.
Copy link to clipboard
Copied
No need for creating new thread, just use the found script with [i] character.
Copy link to clipboard
Copied
The new topic is here:
https://community.adobe.com/t5/bridge-discussions/script-to-copy-file-name-to-keywords/td-p/12591445
The working code for the entire filename as one keyword:
// https://forums.adobe.com/thread/656144
#target bridge
addNametoMeta = {};
addNametoMeta.execute = function(){
var sels = app.document.selections;
for (var i = 0; i < sels.length; i++){
var md = sels[i].synchronousMetadata;
md.namespace = "http://ns.adobe.com/photoshop/1.0/";
var Name = decodeURI(sels[i].name).replace(/\.[^\.]+$/, '');
md.Keywords = md.Keywords + ";" + Name;
}
}
if (BridgeTalk.appName == "bridge"){
var menu = MenuElement.create( "command", "Save Filename in Keywords", "at the end of Tools");
menu.onSelect = addNametoMeta.execute;
}
Copy link to clipboard
Copied
This slightly modifed version will create separate keywords from each word space separator in the filename (which may or may not be helpful depending on your filename structure):
// https://forums.adobe.com/thread/656144
#target bridge
addNametoMeta = {};
addNametoMeta.execute = function () {
var sels = app.document.selections;
for (var i = 0; i < sels.length; i++) {
var md = sels[i].synchronousMetadata;
md.namespace = "http://ns.adobe.com/photoshop/1.0/";
var Name = decodeURI(sels[i].name).replace(/\.[^\.]+$/, '').replace(/ /g, ';');
md.Keywords = md.Keywords + ";" + Name;
}
}
if (BridgeTalk.appName == "bridge") {
var menu = MenuElement.create("command", "Filename to Keywords Space Separated", "at the end of Tools");
menu.onSelect = addNametoMeta.execute;
}