• 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 ,
May 06, 2010 May 06, 2010

Copy link to clipboard

Copied

This should do selected documents...


#target bridge  
   if( BridgeTalk.appName == "bridge" ) { 
addFileName = MenuElement.create("command", "Add FileName to Description", "at the end of Thumbnail");
}
addFileName.onSelect = function () {
   addFileNameToDescription();
   }
function addFileNameToDescription(){
var Prefix = "CMS:";
var sels = app.document.selections;
  for (var i = 0; i < sels.length; i++){
var md = sels.synchronousMetadata;
    md.namespace = "http://purl.org/dc/elements/1.1/";
    var Name = decodeURI(sels.name).replace(/\.[^\.]+$/, '');
    Name = Prefix + Name.replace(/\=/g,':');
    md.description = Name;
  }
}

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
Valorous Hero ,
May 06, 2010 May 06, 2010

Copy link to clipboard

Copied

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 XMPFi...

.name).replace(/\.[^\.]+$/, '');
        Name = Prefix + Name.replace(/\=/g,':');
      myXmp.deletePr...





















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
May 06, 2010 May 06, 2010

Copy link to clipboard

Copied

Brilliant, thanks Paul!

The first one reported an error, but the second works perfectly.

Lewis

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
Explorer ,
Jun 23, 2011 Jun 23, 2011

Copy link to clipboard

Copied

Hi,

I am looking to do this same thing. I don't want to change anything in the file name, however. Just want to copy the filename to the iptc description. I don't know anything about scripting. Can you tell me in layman's terms what I need to do?

Thanks!

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
Guru ,
Jun 23, 2011 Jun 23, 2011

Copy link to clipboard

Copied

Beth, I just made you a quick edit to Paul's Script… It should now just put the file name in the IPTC… As is it is with the extension too is that right? The script…

#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 sels = app.document.selections;            for ( a in sels ) {                      var thumb = new Thumbnail( sels );                      if ( thumb.hasMetadata ) {                                var selectedFile ....name );                                myXmp.deleteProperty( XMPConst.NS_DC, "description" );      ...

Now to use this there are a couple of things to do.

First you need to find where the Adobe 'ExtendScript Toolkit' app is located on your machine? Im on a mac so its down in 'Utilites' folder. If you open that you can cut and paste the above code. Then save it giving it a name and the file extension '.jsx' you can then press the play/run arrow up at the top menu… In Bridge you select the files that you want to do this too. Then use the control key and pick the bottom option…

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
Valorous Hero ,
Jun 23, 2011 Jun 23, 2011

Copy link to clipboard

Copied

Open ExtendScript Toolkit and paste the following code into the new window.

This utility can be found in the relevant folder:-
PC: C:\Program Files\Adobe\Adobe Utilities
MAC: <hard drive>/Applications/Utilities/Adobe Utilities

The script will then be saved to :

Open Bridge

Edit - Preferences - Startup Scripts

At the bottom click the "Reveal Button" this will open the folder where the script should be saved.

Close and restart Bridge.

Accept the new script.

To Use :-

Select your documents

Mouse right mouse click menu and select  "Add FileName to Description"

#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 sels = app.document.selections; for(var a in sels){ var thumb = new Thumbnail(sels);    if(thumb.hasMetadata){       var selectedFile = thumb.spec;          var myXmpFile = new XM....name).replace(/\.[^\.]+$/, '');       myXmp.deleteProperty(XMPConst.NS_DC, "description");       m...

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
Guru ,
Jun 23, 2011 Jun 23, 2011

Copy link to clipboard

Copied

And as if by magic the shopkeeper appeared…

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
Valorous Hero ,
Jun 23, 2011 Jun 23, 2011

Copy link to clipboard

Copied

Hi Mark, disaster here my wonderful laptop has died and I'm having to use the dreaded ghostly coloured laptop with an apple on it! I get a new laptop tomorrow though

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
Explorer ,
Jun 23, 2011 Jun 23, 2011

Copy link to clipboard

Copied

Hi Paul and Mark,

Thanks so much for you replies. Neither is quite working for me yet. I was able to open extendscript tool. I saved to adobe scripts as that is the default. The files show up in the extend script app but I'm not sure how to get them into Bridge. When I click the reveal button in the start up scripts utility nothing happens

Thanks for your help!!

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
Valorous Hero ,
Jun 23, 2011 Jun 23, 2011

Copy link to clipboard

Copied

When you click the reveal button it should open a new Finder window on a Mac or Explorer window on a PC, I haven't known this to fail before.

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
Explorer ,
Jun 23, 2011 Jun 23, 2011

Copy link to clipboard

Copied

I figured it out and it works perfectly!

Thanks again!!!

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
Valorous Hero ,
Jun 23, 2011 Jun 23, 2011

Copy link to clipboard

Copied

Glad it worked for you Beth!

Mark, yes I know where spotlight are, have two of them on the front of my car!

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
Guru ,
Jun 23, 2011 Jun 23, 2011

Copy link to clipboard

Copied

I knew there had to be some reason behind me beating you to a reply… It's not often I get the chance… although Im getting further in the % I get done before you beat me… You know you secretly loves the Apple… What tempted Eve n all that… If you can't find anything on it just use spotlight… Do you know where that is? Does the new one come with Windoz 7 because that was my idea… And Im not great on ideas… Im now having to run a second monitor on the imac with CS5 bloody palettes eat loads of desktop… ESTK is now on the second monitor so I can see what Im doing wrong…

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 ,
Jul 23, 2012 Jul 23, 2012

Copy link to clipboard

Copied

How do I change the script from Description to Document Title. I've tried a couple of things, name changes and what not, and I can't get it to work for me. Otherwise, the script you provided works great. I just need it to add to the Document Title, not the Description. Thanks for your help.

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
Valorous Hero ,
Jul 23, 2012 Jul 23, 2012

Copy link to clipboard

Copied

This copy the filename the the title field..

#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);

         }

    }

}

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 ,
Jul 24, 2012 Jul 24, 2012

Copy link to clipboard

Copied

Paul,

I had some troubles with the code above, so what I did was take the code you had put up with the instructions on how and where to save it and just changed Desc and Description to Title, and it worked! Thank you so much for your help, this script has just saved us a ton of time. Thank you and thank you everyone here for your help.

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 ,
Jul 27, 2012 Jul 27, 2012

Copy link to clipboard

Copied

Ok, so I ran into an issue, the code I used won't work on Camera RAW (.CR2), any ideas on what I can do to fix this? Thanks again for any and all of your help.

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
Valorous Hero ,
Jul 27, 2012 Jul 27, 2012

Copy link to clipboard

Copied

CR2 files are read only so all you can do is amend the xmp file (or create a new xmp if it does not exist) with the required information, as an example...

var sels = app.document.selections;
for(var a in sels){
    setTitle(sels.spec);
    }

function setTitle(thumb){
var Name = decodeURI(thumb.name).replace(/\.[^\.]+$/, '');
var file = new File(thumb.path +"/" +Name +".xmp");
if (ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");
  if(file.exists){
     file.open('r');
     file.encoding = "UTF8";
     file.lineFeed = "unix";
     file.open("r", "TEXT", "????");
     var xmpStr = file.read();
     file.close();
     }else{
         var xmpStr='';
         }
     var xmp = new XMPMeta( xmpStr );
    xmp.deleteProperty(XMPConst.NS_DC, "title");
    xmp.appendArrayItem(XMPConst.NS_DC, "title", Name, 0, XMPConst.ALIAS_TO_ALT_TEXT);
    xmp.setQualifier(XMPConst.NS_DC, "title[1]", "http://www.w3.org/XML/1998/namespace", "lang", "x-default");
     file.open('w');
     file.encoding = "UTF8";
     file.lineFeed = "unix";
     file.write( xmp.serialize() );
     file.close();
};


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 30, 2014 Jun 30, 2014

Copy link to clipboard

Copied

Paul,

I found this script from you: Re: How to Batch copy filename to its metadata Title and used it with great success, but it inserts the filename into the end of the description. Is there a way to modify it to place the filename at the beginning of the description?

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 ,
Dec 10, 2014 Dec 10, 2014

Copy link to clipboard

Copied

Hi Paul, I'm a photographer trying to figure out how to batch copy my FileName into the IPTC Description. My files are Canon CR2.  The original script in this thread works for JPG & TIFF files but as you stated above, the CR2 files are read only. Thank you in advance.

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 ,
Dec 11, 2014 Dec 11, 2014

Copy link to clipboard

Copied

Paul no longer visits these forums since CC was released.

Looking at his code above this should work for RAW files only! (cr2,nef) etc.

#target bridge

//N.B this script should only be used with RAW files CR2,NEF,ORF,MOS etc.

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

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

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

FileNameToDescRaw.onSelect = function () {  

var sels = app.document.selections; 

for(var a in sels){ 

setDesc(sels.spec); 

function setDesc(thumb){ 

var Name = decodeURI(thumb.name).replace(/\.[^\.]+$/, ''); 

var file = new File(thumb.path +"/" +Name +".xmp"); 

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

  if(file.exists){ 

file.open('r'); 
file.encoding = "UTF8"; 
file.lineFeed = "unix";  
file.open("r", "TEXT", "????"); 
var xmpStr = file.read(); 
file.close(); 
}else{ 
     var xmpStr=''; 
    
var xmp = new XMPMeta( xmpStr ); 
xmp.deleteProperty(XMPConst.NS_DC, "description");  
xmp.setLocalizedText( XMPConst.NS_DC, "description", null, "x-default",Name );
file.open('w'); 
file.encoding = "UTF8"; 
file.lineFeed = "unix";  
file.write( xmp.serialize() ); 
file.close(); 

};

};

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 ,
Apr 16, 2015 Apr 16, 2015

Copy link to clipboard

Copied

Running into the same issue. Trying to enter metadata into RAW & DNG files. The open for update does not work with them. DNG files work better, as I think the XMP info is within the file and not in the sidecar file.

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 ,
Apr 16, 2015 Apr 16, 2015

Copy link to clipboard

Copied

I didn't look at the above script very well. that works by working directly on the sidecar file.

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

Hi Paul

I too am an absolute newbie on this topic but it appears to be right up my alley as a solution for automating a lengthy repetitive task I face.

Would it be possible for you to modify and post your script so that it enables the filename in the Bridge window to be copied to the Document Title field in IPTC.

Many thanks

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