11 Replies Latest reply on Jan 12, 2017 1:10 AM by fontlord

    Indesign filename into the meta data automatically

    redtagdm Level 1

      I'd like to be able to add the indesign filename into the meta data xmp (File info/Document Title) automatically on all the documents we work on. The reason being our client changes the file name on the pdf's we send and when they return the pdf to us for amends I have little or no way of locating the file amongst 25,000 documents.

        • 1. Re: Indesign filename into the meta data automatically
          JamesHaney Level 1

          Copy the text between the two lines below.

          Paste it into a text editor and save the file as "storeTitleXMP.jsx"

          In this folder:

          /Applications/Adobe InDesign CC 2014/Scripts/startup scripts/

           

          This script will load at startup of InDesign and will run just before each time the file is saved.

           

          When you view the RAW XML you will see the following listed within the document XMP:

          "        <xmp:LCCDocumentStatus>In Progress</xmp:LCCDocumentStatus>

                   <xmp:LCCUserName>jhaney</xmp:LCCUserName>

                   <xmp:LCCRevisionNotes>More edits</xmp:LCCRevisionNotes>

                   <xmp:InDesignFileName>Untitled-7 copy.indd</xmp:InDesignFileName>

                   <xmp:CreatorTool>Adobe InDesign CC 2014 (Macintosh)</xmp:CreatorTool>

          "

           

          script begins below line

          -------------------------

          #targetengine 'session'

           

          var myEventListener = app.addEventListener("beforeSave", function (myEvent) {

          var doc = app.documents[0];

          var docTitle = (doc.name);

          var myDocXMP = app.activeDocument.metadataPreferences;

          var destNamespace = "http://ns.adobe.com/xap/1.0/";

          var destNodeName = "InDesignFileName";

          var nodeValue = docTitle;

          myDocXMP.setProperty(destNamespace, destNodeName, nodeValue);

          }

          ).name = "storeTitleXMP";

          ------------------------

          script ends above line

           

          Hope this gives you what you need.

          • 2. Re: Indesign filename into the meta data automatically
            JamesHaney Level 1

            To access the extended metadata in Acrobat:

             

            Open file

            Choose menu "Properties"

            with the "Description" tab selected

            Click on the button named "Additional Metadata..."

            Click on "Advanced"

            Click the triangle next to "XMP Core Properties..."

            Your custom field will be listed in the fields presented under this item.

            • 3. Re: Indesign filename into the meta data automatically
              redtagdm Level 1

              Hi James,

               

              If this work it will save me hours of work!! I have tried to load the scrip but I’m getting the below error message in Indesign – what do you think? Sorry to as the question but I know nothing about scripting.

               

              Thanks

               

              Paul

               

              Screen Grab.jpg

              • 4. Re: Indesign filename into the meta data automatically
                Loic.Aigon Adobe Community Professional

                Hi,

                 

                What about this :

                 

                #targetengine "onBeforeOpenAndNew" 
                function main() {
                  //Referencing events
                  var onAfterOpenEvent = app.eventListeners.item("onAfterOpen");
                  var onAfterNewEvent = app.eventListeners.item("onAfterNew");
                  var onAfterSaveEvent = app.eventListeners.item("onAfterSave");
                  var onAfterSaveAsEvent = app.eventListeners.item("onAfterSaveAs");
                
                  //Adding name to description
                  var f = function(evt){
                
                  var doc = evt.target;
                
                  if ( !(doc instanceof Document) ) return;
                
                  var m = doc.metadataPreferences.documentTitle;
                  var dn = doc.name;
                
                  ( m=="" ||  m!=dn ) && doc.metadataPreferences.documentTitle = dn;
                
                  }
                
                  //Adding listeners only is not declared yet
                  !onBeforeOpenEvent.isValid && app.eventListeners.add( "afterOpen", f ).name = "onAfterOpen";
                  !onBeforeNewEvent.isValid && app.eventListeners.add( "afterNew", f ).name = "onAfterNew";
                  !onAfterSaveEvent.isValid && app.eventListeners.add( "afterSave", f ).name = "onAfterSave";
                  !onAfterSaveAsEvent.isValid && app.eventListeners.add( "afterSaveAs", f ).name = "onAfterSaveAs";
                
                
                }
                
                
                //function call
                main();
                

                 

                HTH,

                 

                Loic

                http://www.ozalto.com

                • 5. Re: Indesign filename into the meta data automatically
                  JamesHaney Level 1

                  That's strange, it works on my system. Try this version:

                   

                  #targetengine "storeTitleXMP"

                   

                  var myEventListener = app.addEventListener("beforeSave", function (myEvent) {

                  var doc = app.documents[0];

                  var docTitle = (doc.name);

                  var myDocXMP = app.activeDocument.metadataPreferences;

                  var destNamespace = "http://ns.adobe.com/xap/1.0/";

                  var destNodeName = "InDesignFileName";

                  var nodeValue = docTitle;

                  myDocXMP.setProperty(destNamespace, destNodeName, nodeValue);

                  }

                  ).name = "storeTitleXMP";

                  • 6. Re: Indesign filename into the meta data automatically
                    redtagdm Level 1

                    Okay still having the same error…

                     

                    I have created a .txt document and pasted in;

                     

                     

                    #targetengine "storeTitleXMP"

                     

                     

                     

                    var myEventListener = app.addEventListener("beforeSave", function (myEvent) {

                     

                    var doc = app.documents[0];

                     

                    var docTitle = (doc.name);

                     

                    var myDocXMP = app.activeDocument.metadataPreferences;

                     

                    var destNamespace = "http://ns.adobe.com/xap/1.0/";

                     

                    var destNodeName = "InDesignFileName";

                     

                    var nodeValue = docTitle;

                     

                    myDocXMP.setProperty(destNamespace, destNodeName, nodeValue);

                     

                    }

                     

                    ).name = "storeTitleXMP";

                     

                    Then saved the file naming it; storeTitleXMP.jsx and moved the file to the startup scripts in Indesign.

                    Is this correct??

                    Thanks again

                    • 7. Re: Indesign filename into the meta data automatically
                      JamesHaney Level 1

                      I just followed the instructions just as you described them (copying the script directly from you comment above) and it worked fine for me.

                       

                      It may be that you are storing the text file in rich text format.

                       

                      give me your email and I will send you the script as a plain text file.

                      • 9. Re: Indesign filename into the meta data automatically
                        fontlord

                        Hi Paul

                         

                        Found this thread and wondered if you and James found a resolution for this.

                         

                        I tried the above but I appeared to experience the same issues as you did.

                         

                        Be good to know if you solved it

                         

                        Ta

                        Jo

                        • 10. Re: Indesign filename into the meta data automatically
                          Vamitul Level 4

                          Please use NOTEPAD or similar text editor.
                          save the file as .jsx