8 Replies Latest reply on Sep 23, 2014 8:52 AM by rudytj

    adding name of indesign document to metadata of all images used in document

    rudytj Level 1

      I have been asked to include the indesign file name in the metatag of each image used in every document i produce from here on.

       

      is there a way to write a script in indesign that will copy the document name then open every link (in bridge?) and append the document name to the metadata (i don't want to lose any existing tags) and then save?

       

       

      scott

        • 1. Re: adding name of indesign document to metadata of all images used in document
          Jump_Over Level 5

          Hi,

           

          Looks like a complex issue. Possibly time-intensive.

          But possible using BridgeTalk, I guess.

           

          Jarek

          • 2. Re: adding name of indesign document to metadata of all images used in document
            Laubender Adobe Community Professional & MVP

            Hm?!

            And should the name be removed, if the image is removed from the InDesign document?

             

            Uwe

            • 3. Re: adding name of indesign document to metadata of all images used in document
              Laubender Adobe Community Professional & MVP

              How about InDesign documents with the same name at different locations?

               

              Uwe

              • 4. Re: adding name of indesign document to metadata of all images used in document
                Dirk Becker Level 4

                Before you start with BridgeTalk, have a look at the JavaScript Tools Guide, the chapter about the "XMPScript" code library.

                 

                With that requirement I would write a startup script to listen for link related events and maintain the image files accordingly - that way you could even "unsubscribe" removed links as long the image is still around. For completeness sake also handle the document open, save, revert events to take care of preexisting, foreign, newly created (untitled) or renamed InDesign documents.


                Of course you have to keep in mind that changing XMP will modify the image files and thus require to update the links, so you'd better check whether the data is already present and then don't touch the file. Anyway your admin will love the exploding storage requirements in backup when fat image files start to multiply per use.


                A less obtrusive way for image usage reports would be an explicit menu call when you consider the InDesign document "produced" in the sense of the requirement, and then submit an additional file for the InDesign document to wherever that info is handled.


                Dirk


                Edit: some more document events to consider ;-)

                • 5. Re: adding name of indesign document to metadata of all images used in document
                  -hans- Level 4

                  This should should give you a start. It'll add the active documents name to the field instructions of the img when executed. Tested once. No errorhandling.

                   currDoc = app.activeDocument;
                   docName = currDoc.name;
                   docGraphics = currDoc.allGraphics;
                  
                  for(var g = 0; g < docGraphics.length; g++){
                      currGraphic = docGraphics[g];
                          currGraphicFilePath = currGraphic.itemLink.filePath;
                          fileObject = File(currGraphicFilePath);
                  writeDocNameToMeta(fileObject, docName);
                      }
                  
                  function writeDocNameToMeta(fileObject, docName){
                  if(loadXMPLibrary()){
                          var myFile = fileObject;
                          xmpFile = new XMPFile(myFile.fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_UPDATE);
                          var myXmp = xmpFile.getXMP();
                                var myStatus = myXmp.getProperty(XMPConst.NS_PHOTOSHOP,"Instructions");
                     myXmp.deleteProperty(XMPConst.NS_PHOTOSHOP, "Instructions"); 
                     myXmp.setProperty(XMPConst.NS_PHOTOSHOP, "Instructions", docName);
                     
                    
                     if (xmpFile.canPutXMP(myXmp)) {          xmpFile.putXMP(myXmp);    } 
                        
                          xmpFile.closeFile(XMPConst.CLOSE_UPDATE_SAFELY);
                          unloadXMPLibrary();
                      }
                  }
                  
                  
                      function loadXMPLibrary(){
                          if ( !ExternalObject.AdobeXMPScript ){
                              try{ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript');}
                              catch (e){alert('Unable to load the AdobeXMPScript library!'); return false;}
                          }
                          return true;
                      }
                  
                  function unloadXMPLibrary(){
                          if( ExternalObject.AdobeXMPScript ){
                              try{ExternalObject.AdobeXMPScript.unload(); ExternalObject.AdobeXMPScript = undefined;}
                              catch (e){alert('Unable to unload the AdobeXMPScript library!');}
                          }
                      }
                  

                  Hans-Gerd Claßen

                  • 6. Re: adding name of indesign document to metadata of all images used in document
                    Laubender Adobe Community Professional & MVP

                    @Hans-Gerd – interesting…
                    Never did stuff like that.

                     

                    What will happen in a multi-user environment, if one particular image on a server is placed (removed) from several InDesign documents "at the same" time? I imagine your code plus the idea of Dirk with numerous event handlers writing "constantly" to the images. Is a clash of writing operations by opening, closing files a "likely" case? And what will happen then?

                     

                    Uwe

                    • 7. Re: adding name of indesign document to metadata of all images used in document
                      Dirk Becker Level 4

                      @Uwe - the original request sounded like a single user approach was sufficient. Besides I pointed out that you better avoid too frequent updates. Multi user environments should have some naming/folder conventions in place anyway so users won't collide on each other's image edits, or they will be using editorial systems.

                       

                      The second part of my post - a separate report triggered by explicit menu action - works at any scale. I have a similar reporting program deployed at several sites, each with hundreds of users. As a plugin that program has a few more features and it requires a custom backend server to handle the load, but the principle remains the same.

                      • 8. Re: adding name of indesign document to metadata of all images used in document
                        rudytj Level 1

                        after much though to all the issues that you have brought to my attention this just seems to be a bad idea and it is being scrapped.....thanks for all the help on this failed experiment!!!!

                         

                         

                        scott