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

copy filename to iptc description

Guest
May 06, 2010 May 06, 2010

Copy link to clipboard

Copied

Hello,

I need to create a process of copying the filename of a tiff to the description in that same file's iptc. Ideally i'd like to be able to drop the script in to an Apple Automator process, but that would be a luxury. There's also an extra catch: i need the script to replace "=" with ":" and to add a prefix, for example "CMS:"

Here's an example:

input

filename: 8737=6.tif

description:

output

filename: 8737=6.tif

description: CMS:8737:6

It seems a faily basic process but i don't know where to start with this scripting business... Any help or advise would be much appreciated! Perhaps you know of a really similar one that i can modify??

Lewis

TOPICS
Scripting

Views

12.9K

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

correct answers 1 Correct answer

Valorous Hero , May 06, 2010 May 06, 2010

Yet another version..


#target bridge  
   if( BridgeTalk.appName == "bridge" ) { 
FileNameToDesc = MenuElement.create("command", "Add FileName to Description", "at the end of Thumbnail");
}
FileNameToDesc.onSelect = function () {
   updateFileName();
   }
     
function updateFileName(){
loadXMPLib();
var Prefix = "CMS:";
var sels = app.document.selections;
for(var a in sels){
var thumb = new Thumbnail(sels);
   if(thumb.hasMetadata){
      var selectedFile = thumb.spec;   
      var myXmpFile = new XMPFile( selectedFile.fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_UPDATE);      
      var myXmp = myXmpFile.getXMP();   
      var Name = decodeURI(sels
.name).replace(/\.[^\.]+$/, '');
        Name = Prefix + Name.replace(/\=/g,':');
      myXmp.deleteProperty(XMPConst.NS_DC, "description");
      myXmp.setLocalizedText( XMPConst.NS_DC, "description", null, "x-default",Name );
      if (myXmpFile.canPutXMP(myXmp)) {
    myXmpFile.putXMP(myXmp);
         myXmpFile.closeFile(XMPConst.CLOSE_UPDATE_SAFELY);
         }
      }
}
unloadXMPLib();
}
function loadXMPLib(){
if (ExternalObject.AdobeXMPScript == undefined) {
    ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");
}
}
function unloadXMPLib(){
   if( ExternalObject.AdobeXMPScript ) {
      try{
         ExternalObject.AdobeXMPScript.unload();
         ExternalObject.AdobeXMPScript = undefined;
      }catch (e){ }
   }
}

Votes

Translate

Translate
Valorous Hero ,
Jun 28, 2011 Jun 28, 2011

Copy link to clipboard

Copied

No problem, here you are...


#target bridge  
   if( BridgeTalk.appName == "bridge" ) { 
FileNameToDesc = MenuElement.create("command", "Add FileName to Title", "at the end of Thumbnail");
}
FileNameToDesc.onSelect = function () {
   updateFileName();
   }
     
function updateFileName(){
loadXMPLib();
var sels = app.document.selections;
for(var a in sels){
var thumb = new Thumbnail(sels);
   if(thumb.hasMetadata){
      var selectedFile = thumb.spec;   
      var myXmpFile = new XMPFi...

.name).replace(/\.[^\.]+$/, '');
      myXmp.deleteProperty(XMPConst.NS_DC, "title");
        myXmp.ap...
http://www.w3.org/XML/1998/namespace", "lang", "x-default");
      if (myXmpFile.canPutXMP(myXmp)) {
    myXmpFile.putXMP(myXmp);
         myXmpFile.closeFile(XMPConst.CLOSE_UPDATE_SAFELY);
         }
      }
}
unloadXMPLib();
}
function loadXMPLib(){
if (ExternalObject.AdobeXMPScript == undefined) {
    ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");
}
}
function unloadXMPLib(){
   if( ExternalObject.AdobeXMPScript ) {
      try{
         ExternalObject.AdobeXMPScript.unload();
         ExternalObject.AdobeXMPScript = undefined;
      }catch (e){ }
   }
}

Votes

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 28, 2011 Jun 28, 2011

Copy link to clipboard

Copied

Wow Paul, thanks a ton for sharing. It works great! This saves so much time,  and eliminates cut and paste mistakes.

I am very grateful!

Don

Votes

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 ,
Jul 01, 2015 Jul 01, 2015

Copy link to clipboard

Copied

Is there a way to get this working with CC?

I may not be smart enough but at least I can't get it working in CC.

I have the exact same need as the original top poster.

Votes

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 ,
Jul 01, 2015 Jul 01, 2015

Copy link to clipboard

Copied

So far, I was only able to make changes to the XMP sidecar file. I didn't get it to work with dng's, but all I needed was to be able to get get one or the other to work.

With CC.

Votes

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 ,
Jul 01, 2015 Jul 01, 2015

Copy link to clipboard

Copied

Yes, but I would love to use it on TIF's and other file-formats.

So what I need is a script for Bridge that takes the file name without the ".TIF" or ".JPG" or whatever and puts it in IPTC Title or Description-field.

Votes

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
Guest
Jul 02, 2015 Jul 02, 2015

Copy link to clipboard

Copied

Hi everyone,

this script works very well for me, but I need to write the filename to an IPTC extension field: Source Inventory Number {Artwork or Object detail}

After a long search I finally found this document (https://iptc.org/std/photometadata/specification/IPTC-PhotoMetadata-201410_3.pdf) in wich there is a specification for this field (page 51).

But I can't manage to implement it properly in the code, could someone help me please?

Kind regards,

rd

Votes

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 ,
Jul 02, 2015 Jul 02, 2015

Copy link to clipboard

Copied

I would download the XMP SDK. it is a real pain trying to figure out what works!!!

Adobe - XMP Developer Center | Adobe Developer Connection

Votes

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
Participant ,
Nov 19, 2015 Nov 19, 2015

Copy link to clipboard

Copied

Hi, I need to do this also.

I see here that it's possible to to copy to the Description field, but can someone please adapt this script  ?

My client is asking to put the Filename of thousand images into the field ‘Source Inventory Number’ in the IPTC Extension - Artwork or Object.

I need to do this in Bridge CC.

Also the filename has underscores who has to be changed in slashes when copied: S2004_16_001 should become S2004/16/001 in the field 'Source Inventory Number'; they remain unchanged in the Filename.

Thanks, Dominique

Votes

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 ,
Nov 19, 2015 Nov 19, 2015

Copy link to clipboard

Copied

I'm still trying to figure out how to add various information to the various metadata fields. It can be done, but you have to know the right namespace and structure of each of the fields. I would suggest you ask your question in the XMP SDK forum:

XMP SDK

Votes

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
Participant ,
Nov 19, 2015 Nov 19, 2015

Copy link to clipboard

Copied

Could this document (https://iptc.org/std/photometadata/specification/IPTC-PhotoMetadata-201410_3.pdf) help in wich there is a specification for this field (page 51).

Votes

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 ,
Nov 20, 2015 Nov 20, 2015

Copy link to clipboard

Copied

Yes, I think that is the reference. I've looked at that before, but couldn't figure out how to get it to work.

Votes

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 ,
May 12, 2019 May 12, 2019

Copy link to clipboard

Copied

Hi, I need to do this also.

I see here that it's possible to to copy to the Description field, but can someone please adapt this script  ?

My client is asking to put the Filename of thousand images into the field ‘Source Inventory Number’ in the IPTC Extension - Artwork or Object.

I need to do this in Bridge CC.

Also the filename has underscores who has to be changed in slashes when copied: S2004_16_001 should become S2004/16/001 in the field 'Source Inventory Number'; they remain unchanged in the Filename.

Thanks, Dominique

Hey, I'm four years too late and it would take me a lot longer to hack a Bridge script, however, I like an opportunity to practice... So using the following ExifTool command and chaining two regular expressions together:

exiftool '-XMP-iptcExt:ArtworkSourceInventoryNo<${filename;s/\.[^.]*$//;s/_/\//g}' 'pathtoFILEorFOLDER'

Votes

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
Participant ,
Nov 19, 2015 Nov 19, 2015

Copy link to clipboard

Copied

Is this solved by now ? Because I need this also... 😉

Votes

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 ,
Jul 02, 2015 Jul 02, 2015

Copy link to clipboard

Copied

OK, so this script works for You rd2487, and youre using Bridge CC?

If so then I must be doing something wrong, could you please explain in detail how you get it into Bridge and how You then use it in Bridge.

All the scripts I've tried with show up in the options/startup scripts dialog, but I get no menu item or nothing when I right mouse click, I don't understand how to use it?

Votes

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
Guest
Jul 02, 2015 Jul 02, 2015

Copy link to clipboard

Copied

No I'm using Bridge CS5.

Votes

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 ,
Jul 02, 2015 Jul 02, 2015

Copy link to clipboard

Copied

OK anyone here that gets it to work with CC?

Votes

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 ,
Jul 02, 2015 Jul 02, 2015

Copy link to clipboard

Copied

Here's a script that will put the file name in the description field. Select a thumbnail in Bridge. Run the script from ESTK.

#target bridge

var tSpec, fName, xmpFile, nName;

if (ExternalObject.AdobeXMPScript == undefined) {

    ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript');

}

var doc = app.document

var thumbs = doc.selections

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

  

    tSpec = thumbs.spec;

    fName = tSpec.fsName.split('.')[0];

    var testFile = new File(tSpec)

    readTextFile (testFile)

    };//end for thumbs loop

function readTextFile(file){

      var xmpf = new XMPFile(File(file).fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_UPDATE );

      var xmp = xmpf.getXMP();

                  

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

                  xmp.setProperty( XMPConst.NS_DC, "description", file.name, XMPConst.STRING );

                  if (xmpf.canPutXMP( xmp )) {

                  xmpf.putXMP( xmp );

                  }

            xmpf.closeFile( XMPConst.CLOSE_UPDATE_SAFELY );

    

      }

    

Votes

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
Enthusiast ,
Jul 02, 2015 Jul 02, 2015

Copy link to clipboard

Copied

You are not passing fName to the readTextFile function and only updating the description with the full name including extension.

Votes

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 ,
Jul 02, 2015 Jul 02, 2015

Copy link to clipboard

Copied

Yes, in my example, that's what I'm doing. Whoever wants to modify it to they needs can. This was just an example to get the file name, or anything for that matter, into the description field via Bridge.

Votes

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 ,
Jul 02, 2015 Jul 02, 2015

Copy link to clipboard

Copied

OK, so I run the script above from Adobe Extendscript Toolkit CC (as Extendscript or Bridge?).

Then I run Bridge, and where in Bridge do I find a way to run this script on the files I've selected?

Votes

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 ,
Jul 02, 2015 Jul 02, 2015

Copy link to clipboard

Copied

You just select the thumbnails that you want to run the script on. You can set it up to run from Bridge rather than ESTK, but I didn't include that in the script. I don't do a lot of Bridge scripting, but I did recently need to do this with some images I was digitizing: copying descriptions from my FileMaker database into the description fields of my images.

Votes

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
Guest
Jul 02, 2015 Jul 02, 2015

Copy link to clipboard

Copied

Yes indeed, I can't find what I'm looking for. Some examples with IPTC Extension would be very helpfull. I don't have enough background knowledge to figure it out myself..

Votes

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 ,
Jul 02, 2015 Jul 02, 2015

Copy link to clipboard

Copied

I wish I could help more, but I fish around for the correct way to do this also.

Votes

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
Enthusiast ,
Jul 02, 2015 Jul 02, 2015

Copy link to clipboard

Copied

#target bridge

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

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

FileNameToDesc.onSelect = function () {  

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

var sels = app.document.selections;  

for(var a in sels){ 

var thumb = new Thumbnail(sels);  

   if(thumb.hasMetadata){  

  var selectedFile = thumb.spec;
  var xmpFile = new XMPFile( selectedFile.fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_UPDATE);   
  var xmp = xmpFile.getXMP();
  var Name = decodeURI(sels.name).replace(/\.[^\.]+$/, '');
  var desc = xmp.getProperty(XMPConst.NS_DC, "description"); 
  xmp.deleteProperty(XMPConst.NS_DC, "description");  
  xmp.setLocalizedText( XMPConst.NS_DC, "description", null, "x-default",desc + " " +Name ); 
  if (xmpFile.canPutXMP(xmp)) {  
        xmpFile.putXMP(xmp); 
     xmpFile.closeFile(XMPConst.CLOSE_UPDATE_SAFELY);  
     }  
  }  

};

///////////////////////

This script is for Bridge CS 4 or newer and should append the filename to the end of the description.

The above script should be copied and saved with a .jsx extension and saved into the start-up folder, that can be found by going to the Bridge preferences - Startup Scripts and clicking the "Reveal My Startup Scripts". Make sure the editor does Plain text! or use ExtendScript Toolkit (The Adobe Integrated Development Environment).

Once the script is saved close Bridge if it was open and restart it, it will then prompt you to accept the new script.

To use. Select the required files, must not be any Raw files NEF,CR2 etc. as they would require a different script.

Then Tools - Add FileName to Description

That's it.

Votes

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 ,
Jul 02, 2015 Jul 02, 2015

Copy link to clipboard

Copied

Big thank You Philip Cord, I finally got it working, and the only thing I did different is that I saved the script using Notepad instead of Extendscript.

One thing though, it puts in "undefined" before the filename in the Description field.

If the filename is "image123.tif", in the Description field it writes: "undefined image123"

Votes

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