• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers

Bridge script to write filename to Description, Credit Line, andTitle lines

New Here ,
Jun 06, 2019 Jun 06, 2019

Copy link to clipboard

Copied

Hello! I'm in search of a Bridge script that will write a filename (without file extension) to the description line, title line, and Credit line (without overwriting!) in my IPTC metadata. I've looked around and haven't found something already written that does this and I don't quite have enough skills to write it myself or adapt something that exists already. Any leads or suggestions? Thanks!!

Views

2.9K

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 06, 2019 Jun 06, 2019

Copy link to clipboard

Copied

I don't have one script that does all three... But I do have three separate scripts. I could possibly combine them with time/effort, but no promises as I'm new to scripting.

I did manage to hack an existing script to add the Filename to the Headline into the Credit:

// Bridge script to write filename to Description, Credit Line, andTitle lines

// https://forums.adobe.com/thread/656144 

// https://forums.adobe.com/message/9744916 

// https://forums.adobe.com/message/9745231 

#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(/\.[^\.]+$/g, ' '); //remove extension  

    md.Credit = md.Credit + Name; 

  } 

if (BridgeTalk.appName == "bridge"){ 

var menu = MenuElement.create( "command", "Add filename to Credit", "at the end of Tools"); 

  menu.onSelect = addNametoMeta.execute; 

}

Here is the code for Filename to Description:

// https://forums.adobe.com/message/10061534#10061534

// https://forums.adobe.com/message/3595421#3595421

#target bridge

   if( BridgeTalk.appName == "bridge" ) {

fileToDesc = MenuElement.create("command", "Add FileName to Description", "at the end of Tools");

}

fileToDesc.onSelect  = function () {

var thumbs = app.document.selections;

if (ExternalObject.AdobeXMPScript == undefined)  ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");

for(var a =0;a<thumbs.length;a++){

var selectedFile =  new Thumbnail(thumbs);

app.synchronousMode = true;

var xmp = new XMPMeta(selectedFile.synchronousMetadata.serialize());

var Desc = getArrayItems(XMPConst.NS_DC, "description");

if(Desc != "") Desc+= ";";

xmp.deleteProperty(XMPConst.NS_DC, "description");

xmp.setLocalizedText( XMPConst.NS_DC, "description", null, "x-default", Desc +=  decodeURI(selectedFile.spec.name).replace(/\..+$/,""));

var newPacket = xmp.serialize(XMPConst.SERIALIZE_USE_COMPACT_FORMAT);

selectedFile.metadata = new Metadata(newPacket);

    }

ExternalObject.AdobeXMPScript.unload();

ExternalObject.AdobeXMPScript = undefined;

function getArrayItems(ns, prop){

var arrItem=[];

try{

var items = xmp.countArrayItems(ns, prop);

for(var i = 1;i <= items;i++){

arrItem.push(xmp.getArrayItem(ns, prop, i));

}

return arrItem.toString();

}catch(e){alert(e +" Line: "+ e.line);}

    }

};

Here is the code for Filename to Title:

// https://imagesimple.wordpress.com/2011/08/24/cs5-filename-to-title-script/

#target bridge

   if( BridgeTalk.appName == "bridge" ) {

FT = MenuElement.create("command", "Add FileName to Title", "at the end of Tools");

}

FT.onSelect = function () {

   AddFilenameToTitle();

   }

function AddFilenameToTitle(){

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.spec;

var Title = decodeURI(selectedFile.name).replace(/\.[^\.]+$/, '')

      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", Title, 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);

         }

    }

}

After running all three scripts, I used ExifTool to confirm which metadata tags were written:

[IPTC]           ObjectName                    

[IPTC]           Credit                         

[IPTC]           Caption-Abstract               

[IFD0]           ImageDescription               

[XMP-dc]     Title                          

[XMP-dc]     Description                    

[XMP-photoshop]    Credit

And here is the result from Bridge's Metadata panel for a file titled "colour FILE-Test.psd":

results.png

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 06, 2019 Jun 06, 2019

Copy link to clipboard

Copied

An equivalent ExifTool command line could be:

exiftool '-IPTC:ObjectName<${filename;s/\.[^.]*$//}' '-IPTC:Credit<${filename;s/\.[^.]*$//}' '-IPTC:Caption-Abstract<${filename;s/\.[^.]*$//}' '-IFD0:ImageDescription<${filename;s/\.[^.]*$//}' '-XMP-dc:Title<${filename;s/\.[^.]*$//}' '-XMP-dc:Description<${filename;s/\.[^.]*$//}' '-XMP-photoshop:Credit<${filename;s/\.[^.]*$//}' -r 'pathTOfileORfolder'

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 16, 2019 Dec 16, 2019

Copy link to clipboard

Copied

I can't seem to get this to run properly in Adobe Bridge CC 10.0.1 - there's just no feedback at all. I copied it into a notepad, saved it as a .jsx file (file properties confirm that it is a JSX file), installed it in the proper folder, Bridge asked me if I wanted to enable it (clicked yes). Then it appears in the proper dropdown (Tools), yet it appears to do nothing. I get no feedback period and none of the metadata changes. Do you know what I might be doing wrong? 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 17, 2020 May 17, 2020

Copy link to clipboard

Copied

It's hard to believe that in 2020 this feature is not a standard in Adobe - All photographers use META and for me the best program for writing it is ACDSee as this feature has existed for a decade, but I am looking at swapping to Adobe products but all these limitations with XMP over XML are putting me off switching over. It would be nice if we had a way of just selecting a Parent folder, then everything inside those folders get written too, this is possible in ACDSee but you have toi tag each folder which makes it a long winded process but wtill much better than this Bridge nonsense 😕

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 11, 2020 Jun 11, 2020

Copy link to clipboard

Copied

Did you ever find a Bridge script to write filename to Description? I too am interested in finding a script like this for the newest version of Adobe Bridge. Can you share any resources?

Morgan Howarth

[Edit by moderator: I've taken out your public email, you probably do not want to share that with everyone]

 

Please PM me if you have information! Thank you.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 12, 2020 Jun 12, 2020

Copy link to clipboard

Copied

I personally have not found a way to do it, I got ACDSee Professional thinking that would do it for me, but the system is so trashy, having to manually select each and every folder in a pull down menu and no way to select all sub-folders in a parent folder, it's an antiquated system at best, when I added one parent folder with all my location shots the program ceased to work properly, it now takes 10 minutes just to load up so I need to remove all the catalog files and start again 😞 
ACDsee does write the tags perfectly if you are willing to manually set each folder, but for me (I have over 100,000 photographs I'd like to change the EXIF on) this is no good.

It seems all we want is a simple program to read an XML file and write the relevant tags, hard to believe such a thing does not exist.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 12, 2020 Jun 12, 2020

Copy link to clipboard

Copied

 

I posted the following code earlier in the topic thread, which adds the file name to the description field, removing the filename extension...

 

 

#target bridge
   if( BridgeTalk.appName == "bridge" ) {
fileToDesc = MenuElement.create("command", "Add FileName to Description", "at the end of Tools");
}
fileToDesc.onSelect  = function () {
var thumbs = app.document.selections;
if (ExternalObject.AdobeXMPScript == undefined)  ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");
for(var a =0;a<thumbs.length;a++){
var selectedFile =  new Thumbnail(thumbs);
app.synchronousMode = true;
var xmp = new XMPMeta(selectedFile.synchronousMetadata.serialize());
var Desc = getArrayItems(XMPConst.NS_DC, "description");
if(Desc != "") Desc+= ";";
xmp.deleteProperty(XMPConst.NS_DC, "description");
xmp.setLocalizedText( XMPConst.NS_DC, "description", null, "x-default", Desc +=  decodeURI(selectedFile.spec.name).replace(/\..+$/,""));
var newPacket = xmp.serialize(XMPConst.SERIALIZE_USE_COMPACT_FORMAT);
selectedFile.metadata = new Metadata(newPacket);
    }
ExternalObject.AdobeXMPScript.unload();
ExternalObject.AdobeXMPScript = undefined;
function getArrayItems(ns, prop){
var arrItem=[];
try{
var items = xmp.countArrayItems(ns, prop);
for(var i = 1;i <= items;i++){
arrItem.push(xmp.getArrayItem(ns, prop, i));
}
return arrItem.toString();
}catch(e){alert(e +" Line: "+ e.line);}
    }
};

 

 

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 12, 2020 Jun 12, 2020

Copy link to clipboard

Copied

Using ExifTool, the command line code to copy the filename to the description metadata tag without extension would be:

 

 

exiftool '-description<${filename;s/\.[^\.]+$//}' -r 'path to file or folder here'

 

 

This command line code example is from the Mac, on Windows simply change the single straight quote/foot mark ' to straight double quote/inch marks " with the correct platform-specific path to the file or top-level folder. It uses a recursive argument to process all files in all folders under the top-level folder. Further arguments can be added to only process certain file types or to ignore specific directories under the top-level directory path. This code duplicates and renames the original file for safety, and one can add the -overwrite_original argument to turn off this behaviour.

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 29, 2021 Mar 29, 2021

Copy link to clipboard

Copied

So did anyone get the file name into the Title and Description Metatag with a Bridge script?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 29, 2021 Mar 29, 2021

Copy link to clipboard

Copied

My Filename to Title script will do that, you'd have to modify it to write into description as well.

 

https://www.dropbox.com/sh/mg817g9a9ymbasi/AADTmXUVxmFfM58bcyYE7yiwa?dl=0

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 30, 2021 Mar 30, 2021

Copy link to clipboard

Copied

It works great with the title, and I could get it to do the description but I couldnt figure out how to get it to do both at the same time since I'm not a programmer. I tried a bunch of different things that I thought would work but they didnt.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 29, 2021 Mar 29, 2021

Copy link to clipboard

Copied

I'm pretty sure that I have a script that writes to both, I'll dig it up when I have time...

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 30, 2021 Mar 30, 2021

Copy link to clipboard

Copied

That would be great! I downloaded Bridge Utility Script Pack and that worked great for putting the file name in the title metatag. I could do a search and replace the word title with description and then it did description. But since I'm not a programer i couldnt figure out how to add description to the title scipt. I wish someone had a script that you could have the option to populate any and all the metatag data. Right now I'm running two scripts in Bridge and in Photoshop I'm added Copyright, Copyright Notice and Author with a action. Thank you for your help!

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 04, 2021 Apr 04, 2021

Copy link to clipboard

Copied

 

MarkLane1 

 

It turns out that I didn't have a script that writes the filename to both the Description and Title metadata fields.

 

I have adjusted an existing script for Description to also include the Title:

 

/* Original script modified by Stephen Marsh - 2021
https://community.adobe.com/t5/bridge/bridge-script-to-write-filename-to-description-credit-line-andtitle-lines/td-p/10489128
https://forums.adobe.com/thread/2009311 */

#target bridge

if (BridgeTalk.appName == "bridge") {
    FT = MenuElement.create("command", "Add Filename to Description and Title", "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).replace(/\.[^\.]+$/, '');
        var myXmpFile = new XMPFile(selectedFile.fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_UPDATE);
        var myXmp = myXmpFile.getXMP();
        var Desc = [];
        var Title = [];
        var descCount = myXmp.countArrayItems(XMPConst.NS_DC, "description");
        var titleCount = myXmp.countArrayItems(XMPConst.NS_DC, "title");

        for (var i = 1; i <= descCount; i++) {
            Desc.push(myXmp.getArrayItem(XMPConst.NS_DC, "description", i));
        }

        for (var i = 1; i <= titleCount; i++) {
            Title.push(myXmp.getArrayItem(XMPConst.NS_DC, "title", i));
        }

        Desc = Desc.toString() + " " + FileName;
        Title = Desc;

        myXmp.deleteProperty(XMPConst.NS_DC, "description");
        myXmp.appendArrayItem(XMPConst.NS_DC, "description", Desc, 0, XMPConst.ALIAS_TO_ALT_TEXT);
        myXmp.setQualifier(XMPConst.NS_DC, "description[1]", "http://www.w3.org/XML/1998/namespace", "lang", "x-default");

        myXmp.deleteProperty(XMPConst.NS_DC, "title");
        myXmp.appendArrayItem(XMPConst.NS_DC, "title", Title, 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);
        }
    }
}

 

https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html

 

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 05, 2021 Apr 05, 2021

Copy link to clipboard

Copied

I was searching for a way to do just this, and found the original Script by John Beardsworth works with changes to the meta line needed. But I was wondering, is there a way to have only part of the file name placed into each line, on mass?
eg. I have a filename structure of:  

ABCD 0123 ABCD AB-CD AB19 0123 AB19 AB19.jpg

so sections:

A B C D E F G H.jpg

Basicly a whole mix of alphanumerics some fixed length some not. All delimiters are spaces (but can be anything).

I was wondering if it was possible to write section A to, say, Comments. B to City, C to Source, D to Headline, etc....

So far I've been doing it long hand by renaming the files to only the relevant section Setting the metadata with johns script and reverting the filename, repeating for each section. I am using a dusted off copy of cs6 as i cant get these to run in CC.
I know there is a way to do this in ExifTool but I'm still learning the syntax and cant figure out the right commands, plus if im not around at least someone else can just hit a button in Bridge with out me explaining how to work Exiftool to them.

Any help would be greatly appreciated.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 05, 2021 Apr 05, 2021

Copy link to clipboard

Copied

I'm not following the pattern, however, once a consistent pattern is found it should be easy enough with a regular expression or another method...

 

Please colour code or bold the source:

 

ABCD 0123 ABCD AB-CD AB19 0123 AB19 AB19.jpg

 

So that I can see how you get:

 

A B C D E F G H.jpg

 

And it is usally best to supply more than one set of before after, say 3 to 6 examples just in case the pattern is not consistent.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 05, 2021 Apr 05, 2021

Copy link to clipboard

Copied

Stephen, thank you very much.

 

here are some example file names in use:

NEWB 1946 James Hunter-Smith 6MK3 2020 11K64976EC012 16K84.jpg

BERW 0763 Thomas Greig 1S6 2019 16E18433H6401 65T54.jpg

BEE 6818 Martin Graham 7K 2020 18L664F38423 89U35.jpg

 

A B C D E G H.jpg

 

Only B, F & H are fixed length, A can be made to be fixed at 4 letters

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 05, 2021 Apr 05, 2021

Copy link to clipboard

Copied

I'm still not following.

 

The dark blue colour coding for example, there is no A in the before text, however, your after text has A in dark blue. Same for red, the source is digits, the output is a red B.

 

What is the logical pattern?

 

Can you explain it such as in the first group, the first character only, in the second group separated by a space it is the last two digits etc.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 05, 2021 Apr 05, 2021

Copy link to clipboard

Copied

Sorry, I was tryig to descrive each section as secion A, section B etc.... the pattern follows the colors only. 

The Blue section is only lettering, but can be 3 or 4 letters long.

The Red section is only ever 4 numbers.

Green and Pink are always names but may contain a hyphen.

Burnt Orange is a mix of letters and numbers and could be any length.

Black is always just 4 numbers.

Light Blue is always a mix of numbers and letters between 7 and 9 characters long.

Indigo is always a mix of numbers and letters 5 characters long.

 

All the delimiters are spaces but they can be made to be anything.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 05, 2021 Apr 05, 2021

Copy link to clipboard

Copied

The Meta lines that work are

Description

Headline

Source

City

Sublocation

State/Province

Iso Country Code

Country

It doesnt matter which is used for what section of the filename.

Sorry if i confused the issue trying to describe sections. 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 05, 2021 Apr 05, 2021

Copy link to clipboard

Copied

Only one metadata field will be requied, the regular expression can transform using your pattern and write the result to the single field. Or the same regular expression can be used/saved into a Batch Rename string substitution preset. Do you really need to capture the 8 separate filename groups? What then? Re-order them? What?

 

I still need you to spell out exactly what the transform should be, if this is the source:

 

NEWB 1946 James Hunter-Smith 6MK3 2020 11K64976EC012 16K84.jpg

 

What should the after/result be? Sorry, I'm just not seeing it...

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 05, 2021 Apr 05, 2021

Copy link to clipboard

Copied

Its the seperate fields I am hoping to achieve. eg:

the Blue section fills the Description field.

Red into Headline

Green into Source

Pink into City

Etc...

so each line of meta data contains one part of the whole filename as each is relevant in differnt ways.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 05, 2021 Apr 05, 2021

Copy link to clipboard

Copied

There may be a better way, which is why I am trying to understand what you are doing or hoping to achive.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 05, 2021 Apr 05, 2021

Copy link to clipboard

Copied

Does that make sense? Sorry, I'm not describing it very well.

NEWB 1946 James Hunter-Smith 6MK3 2020 11K64976EC012 16K84.jpg

 

Blue section fills the Description field: NEWB

Red into Headline 1946 

Green into Source James

Pink into City Hunter-Smith

Orange into Sublocation 6MK3

Black into State/Province 2020

Light Blue into ISOCountryCode 11K64976EC012

Indigo into Country 16K84

 

and the original full filename remains the filename.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines