6 Replies Latest reply on Aug 7, 2015 1:03 PM by BenCloutier-kuQIDz

    How to remove xmp metadata?

    Maria prabhudoss Level 1

      I need to remove the "XMP metadata" information in the tiff(photoshop) files via scripting. Is it possible? Kindly advice me. Please provide examples.

       

      Thanks for looking into this..

       

      Regards,

      Maria Prabudass

        • 1. Re: How to remove xmp metadata?
          Paul Riggott Level 6

          Only some of the metadata can be removed via scripting as some schemas are read only.

          The best way would be to use ExifTool ...

          http://www.sno.phy.queensu.ca/~phil/exiftool/

          1 person found this helpful
          • 2. Re: How to remove xmp metadata?
            Maria prabhudoss Level 1

            Thanks. Is it possible via scripting?

            • 3. Re: How to remove xmp metadata?
              Paul Riggott Level 6

              It depends on what metadata you want removed.

              • 4. Re: How to remove xmp metadata?
                Maria prabhudoss Level 1

                I need to remove the complete metadata except readonly schemas via scripting. Kindly advice me with examples.

                 

                Thanks for looking into this.............

                • 5. Re: How to remove xmp metadata?
                  Paul Riggott Level 6

                  This will remove as much metadata that is possible by using scripting, anything else you need ExifTool.

                   

                   

                  #target photoshop
                  var f = File(Folder.desktop + "/example.tif");
                  removeMetadata(f);
                  function removeMetadata( file){
                  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();
                          XMPUtils.removeProperties(xmp, "", "", XMPConst.REMOVE_ALL_PROPERTIES);
                        if (xmpf.canPutXMP( xmp )) {
                           xmpf.putXMP( xmp );
                        }
                        xmpf.closeFile( XMPConst.CLOSE_UPDATE_SAFELY );
                  };
                  
                  

                  The only other way is to save for web, open the file again and save as a tif.

                  • 6. Re: How to remove xmp metadata?
                    BenCloutier-kuQIDz Level 1

                    A little late but here's a version for batch processing. It is a combination of Paul Riggott  code and another one in the forum.

                    #target photoshop 
                        
                    // Use folder selection dialogs to get the location of the input files
                    // and where to save the new output files.
                    
                    var topFolder = Folder.selectDialog ("Où se trouvent les images à convertir?.", Folder.desktop);
                    var fileandfolderAr = scanSubFolders(topFolder,/\.(jpg|tif|psd|bmp|gif|png|eps)$/i);
                    var fileList = fileandfolderAr[0];
                    
                    for (var i = 0; i < fileList.length; i++){
                        if(!fileList[i].toString().match(/\.DS_Store|\.BridgeSort/g)){
                            var f = fileList[i];
                    
                            removeMetadata(f);  
                            function removeMetadata( file){  
                            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();  
                                    XMPUtils.removeProperties(xmp, "", "", XMPConst.REMOVE_ALL_PROPERTIES);  
                                  if (xmpf.canPutXMP( xmp )) {  
                                     xmpf.putXMP( xmp );  
                                  }  
                                  xmpf.closeFile( XMPConst.CLOSE_UPDATE_SAFELY );  
                            };
                        }
                    }
                    
                    
                    
                    //https://forums.adobe.com/message/5470274
                    function scanSubFolders(tFolder, mask) { // folder object, RegExp or string
                        var sFolders = new Array();
                        var allFiles = new Array();
                        sFolders[0] = tFolder;
                        for (var j = 0; j < sFolders.length; j++){ // loop through folders            
                            var procFiles = sFolders[j].getFiles();
                            for (var i=0;i<procFiles.length;i++){ // loop through this folder contents
                                if (procFiles[i] instanceof File ){
                                    if(mask==undefined) allFiles.push(procFiles[i]);// if no search mask collect all files
                                    if (procFiles[i].fullName.search(mask) != -1) allFiles.push(procFiles[i]); // otherwise only those that match mask
                            }else if (procFiles[i] instanceof Folder){
                                sFolders.push(procFiles[i]);// store the subfolder
                                scanSubFolders(procFiles[i], mask);// search the subfolder
                             }
                          }
                       }
                       return [allFiles,sFolders];
                    };