0 Replies Latest reply on Aug 27, 2015 7:20 PM by nguyễnm10059378

    How to creat PTS script read out all pictures in a folder (include pictures in all subfolders)

    nguyễnm10059378 Level 1

      To help photoshop work more effectively, I want to write a script that

      • Read out all pictures in a folder (include pictures in all subfolders). Show a dialog to input directory path, standard dpi (only numeric input is allow to type in)
      • Write out list of pictures have the incorrect information to a text file (text file will be generated in the folder has inputted) with following fields: filename (full path), name of first layer, dpi.

      Can you guide me?

      Here's the code for reading the folder and subfolder, you can give me comment about it is not?


      var topFolder = new Folder('~/desktop/test');

      var fileandfolderAr = scanSubFolders(topFolder,/\.(jpg|tif|psd|bmp|gif|png|)$/i);

      var fileList = fileandfolderAr[0];

      for(var a = 0 ;a < fileList.length; a++)


      var docRef = open(fileList[a]);

      //do things here


      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];