Skip to main content
This topic has been closed for replies.

1 reply

Paul Riggott
Inspiring
January 31, 2013

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/

Known Participant
January 31, 2013

Thanks. Is it possible via scripting?

BenCloutier-kuQIDz
Known Participant
August 7, 2015

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

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


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.toString().match(/\.DS_Store|\.BridgeSort/g)){

        var f = fileList;

        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.getFiles();

        for (var i=0;i<procFiles.length;i++){ // loop through this folder contents

            if (procFiles instanceof File ){

                if(mask==undefined) allFiles.push(procFiles);// if no search mask collect all files

                if (procFiles.fullName.search(mask) != -1) allFiles.push(procFiles); // otherwise only those that match mask

        }else if (procFiles instanceof Folder){

            sFolders.push(procFiles);// store the subfolder

            scanSubFolders(procFiles, mask);// search the subfolder

         }

      }

   }

   return [allFiles,sFolders];

};