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

Use Filename as Basis to Set Various Metadata Properties

New Here ,
Sep 01, 2012 Sep 01, 2012

Hi,

I have folders full of images. The filenames will be in the form of

ARTIST#EVENT#PHOTOGRAPHER#RANDOMNUMBER.jpg but could also potentially be

ARTIST at EVENT by PHOTOGRAPHER - RANDOMNUMBER.jpg. I'm happy to use whichever is easier. Basically I can set any delimiter I want and vary it up if needed

I have seen a few examples where the filename is set to the title, description etc but I'm having no luck editing the files to what I need. Ideally I'd like

Document Title: Artist at Event by Photographer

Author: Photographer

Description: Artist at Event by Photographer courtesy of Company Name

Keywords: Artist, Event, Photographer, Company Name

I presume this is possible but was hoping some kind soul out there could help!

Thanks in advance,

JJ

TOPICS
Scripting
1.5K
Translate
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 ,
Sep 01, 2012 Sep 01, 2012

Here is an example, but I don't know where you are going to get the company name?

This example is using the first filename example....

//To be run from ExtendScript Toolkit
#target bridge
app.document.deselectAll();
var thumbs = app.document.getSelection("jpg");
for(var a in thumbs){
var f =thumbs.spec;
var parts = decodeURI(f.name).replace(/- \d+.jpg$/i,'').split('#');
if(parts.length == 3){
setMe...

function setMetadata( file, parts ){
var Title = parts[0].toString() + " at " + parts[1].toString() + " by " + parts[2].toString();
var Desc = parts[0].toString() + " at " + parts[1].toString() + " by " + parts[2].toString();
var Author = parts[2].toString();
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.appendArrayItem(XMPConst.NS_DC, "title", Title, 0, XMPConst.ALIAS_TO_ALT_TEXT);
        xmp.setQualifier(XMPConst.NS_DC, "title[1]", "http://www.w3.org/XML/1998/namespace", "lang", "x-default");
        xmp.deleteProperty(XMPConst.NS_DC, "description");
        xmp.setLocalizedText( XMPConst.NS_DC, "description", null, "x-default", Desc );
        xmp.deleteProperty(XMPConst.NS_DC, "creator");
         xmp.appendArrayItem(XMPConst.NS_DC, "creator", Author, 0, XMPConst.ARRAY_IS_ORDERED);
        for(var s in parts){
        xmp.appendArrayItem(XMPConst.NS_DC, "subject", parts, 0,XMPConst.PROP_IS_ARRAY);
        }
      if (xmpf.canPutXMP( xmp )) {
         xmpf.putXMP( xmp );
      }
      xmpf.closeFile( XMPConst.CLOSE_UPDATE_SAFELY );
}


Translate
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 ,
Aug 22, 2013 Aug 22, 2013
LATEST

I'm now using Adobe CC and the script doesn't seem to work anymore

i select the images, click on the option under "tools" and nothing happens. It just goes back to view the desktop. This is my file in full

#target bridge  

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

var vfRename = new MenuElement( "command", "VF Rename", "at the end of Tools" , "vfRename01" );

}

vfRename.onSelect = function () {

app.document.deselectAll();

var thumbs = app.document.getSelection("jpg");

for(var a in thumbs){

var f =thumbs.spec;

var parts = decodeURI(f.name).replace(/- \d+.jpg$/i,'').split('#');

if(parts.length == 3){

setMetadata( File(f), parts )

    }

}

function setMetadata( file, parts ){

var Title = parts[0].toString() + " at " + parts[1].toString() + " by " + parts[2].toString();

var Desc = parts[0].toString() + " at " + parts[1].toString() + " by " + parts[2].toString();

var Author = parts[2].toString();

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.appendArrayItem(XMPConst.NS_DC, "title", Title, 0, XMPConst.ALIAS_TO_ALT_TEXT);

        xmp.setQualifier(XMPConst.NS_DC, "title[1]", "http://www.w3.org/XML/1998/namespace", "lang", "x-default");

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

        xmp.setLocalizedText( XMPConst.NS_DC, "description", null, "x-default", Desc );

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

         xmp.appendArrayItem(XMPConst.NS_DC, "creator", Author, 0, XMPConst.ARRAY_IS_ORDERED);

        for(var s in parts){

        xmp.appendArrayItem(XMPConst.NS_DC, "subject", parts, 0,XMPConst.PROP_IS_ARRAY);

        }

      if (xmpf.canPutXMP( xmp )) {

         xmpf.putXMP( xmp );

      }

      xmpf.closeFile( XMPConst.CLOSE_UPDATE_SAFELY );

}

}

Translate
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