4 Replies Latest reply on Apr 13, 2016 2:54 AM by ibrahimh87713730

    Image Name to Metadata Title

    ibrahimh87713730 Level 1

      Hello everyone,

       

      Any one has a script for bridge or apple script to copy the image name (Image.psd) to a its Metadata Title caption author, etc.. without the extension (.psd)

       

      Thank You

        • 1. Re: Image Name to Metadata Title
          SuperMerlin Level 5

          There are various examples in this thread. copy filename to iptc description

          • 2. Re: Image Name to Metadata Title
            Stephen_A_Marsh Adobe Community Professional
            // 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[a].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);
                    }
                }
            }
            
            • 3. Re: Image Name to Metadata Title
              Stephen_A_Marsh Adobe Community Professional
              // Filename to metadata title.jsx
              // https://forums.adobe.com/message/3596812
              #target bridge
                if( BridgeTalk.appName == "bridge" ) {
              FT = MenuElement.create("command", "Add FileName to Description", "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 count =  myXmp.countArrayItems(XMPConst.NS_DC, "description");
              for(var i = 1;i <= count;i++){
              Desc.push(myXmp.getArrayItem(XMPConst.NS_DC, "description", i));
                  }
              Desc=Desc.toString() + " " + FileName;
                      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");
                      if (myXmpFile.canPutXMP(myXmp)) {
                      myXmpFile.putXMP(myXmp);
                      myXmpFile.closeFile(XMPConst.CLOSE_UPDATE_SAFELY);
                      }
                  }
              }
              
              • 4. Re: Image Name to Metadata Title
                ibrahimh87713730 Level 1

                The first code was the correct one the second one added a space before the name..

                 

                Thank you