6 Replies Latest reply on Mar 7, 2012 7:16 PM by sasientry

    I need to Save file add 3 digit sequence almost i finished but i need some help

    sasientry Level 1

      Hi all

       

      Almost i finished this script but i need three digit sequence only

       

      But now it saved single digit only

       

      When i run more than 100 file in one batch

       

      I need to save FileName_001.Extension

                            FileName_011.Extension

                            FileName_101.Extension

                            FileName_111.Extension

                            FileName_999.Extension

       

      Now it saved only single digit

       

      Please correct it

       

       

      // enable double clicking from the Macintosh Finder or the Windows Explorer

      #target photoshop

       

       

      gFilesToSkip = Array( "db", "xmp", "thm", "txt", "doc", "md0", "tb0", "adobebridgedb", "adobebridgedbt", "bc", "bct" );

       

       

       

       

      var inputFolder = Folder.selectDialog("Select a folder of documents to process");

       

       

       

       

      OpenFolder();

       

       

       

       

      function OpenFolder() {

              var filesOpened = 0;

             

              var fileList = inputFolder.getFiles();

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

             

                      if ( fileList[i] instanceof File && ! fileList[i].hidden && ! IsFileOneOfThese( fileList[i], gFilesToSkip )) {

                              open( fileList[i] );

                              filesOpened++;

                             var docPath = createFolder("~/Desktop/EPS");

                              var suffix ="_";

                          var fileName =activeDocument.name.match(/(.*)\.[^\.]+$/)[1];

                          var epsFile = new File( docPath+"/"+fileName+suffix+[i]+'.eps');

                          var doc = app.activeDocument;

       

       

                  epsSaveOptions = new EPSSaveOptions()

                  epsSaveOptions.embedColorProfile = true

                  epsSaveOptions.encoding=SaveEncoding.JPEGMAXIMUM

                  app.activeDocument.saveAs(epsFile, EPSSaveOptions, true,Extension.LOWERCASE)

                  app.activeDocument.close( SaveOptions.DONOTSAVECHANGES );

                      }

              }

              return filesOpened;

      }

       

       

      function IsFileOneOfThese( inFileName, inArrayOfFileExtensions ) {

                var lastDot = inFileName.toString().lastIndexOf( "." );

                if ( lastDot == -1 ) {

                          return false;

                }

                var strLength = inFileName.toString().length;

                var extension = inFileName.toString().substr( lastDot + 1, strLength - lastDot );

                extension = extension.toLowerCase();

                for (var i = 0; i < inArrayOfFileExtensions.length; i++ ) {

                          if ( extension == inArrayOfFileExtensions[i] ) {

                                    return true;

                          }

                }

                return false;

      }

       

       

       

       

       

       

      function createFolder (thePath) {

           var theFolder = Folder(thePath);

           if (theFolder.exists == false) {theFolder.create()};

           return(theFolder)

           };

        • 1. Re: I need to Save file add 3 digit sequence almost i finished but i need some help
          yajiv_viki Level 2

          Hi Sasi,

           

          Here is the corrected code....

           

          -yajiv

          // enable double clicking from the Macintosh Finder or the Windows Explorer

           

          #target photoshop

          gFilesToSkip = Array( "db", "xmp", "thm", "txt", "doc", "md0", "tb0", "adobebridgedb", "adobebridgedbt", "bc", "bct" );

          var inputFolder = Folder.selectDialog("Select a folder of documents to process");

           

          OpenFolder();

          function OpenFolder() {

                  var filesOpened = 0;

                  var fileList = inputFolder.getFiles();

                  for ( var i = 1; i < fileList.length; i++ ) {

                          if ( fileList[i] instanceof File && ! fileList[i].hidden && ! IsFileOneOfThese( fileList[i], gFilesToSkip )) {

                                  open( fileList[i] );

                                  filesOpened++;

                                 var docPath = createFolder("~/Desktop/EPS");

                                  var suffix ="_";

                              var fileName =activeDocument.name.match(/(.*)\.[^\.]+$/)[1];

                              if(i>0 && i<10){

                                  var epsFile = new File( docPath+"/"+fileName+suffix+"00"+[i]+'.eps');

                                  }

                               if(i>9 && i<100){

                                  var epsFile = new File( docPath+"/"+fileName+suffix+"0"+[i]+'.eps');

                                  }

                              if(i>99){

                                  var epsFile = new File( docPath+"/"+fileName+suffix+[i]+'.eps');

                                  }

                                 

                              var doc = app.activeDocument;

                              epsSaveOptions = new EPSSaveOptions()

                              epsSaveOptions.embedColorProfile = true

                              epsSaveOptions.encoding=SaveEncoding.JPEGMAXIMUM

                              app.activeDocument.saveAs(epsFile, EPSSaveOptions, true,Extension.LOWERCASE)

                              app.activeDocument.close( SaveOptions.DONOTSAVECHANGES );

                          }

                  }

                  return filesOpened;

              }

           

               function IsFileOneOfThese( inFileName, inArrayOfFileExtensions ) {

                    var lastDot = inFileName.toString().lastIndexOf( "." );

                    if ( lastDot == -1 ) {

                              return false;

                    }

                    var strLength = inFileName.toString().length;

                    var extension = inFileName.toString().substr( lastDot + 1, strLength - lastDot );

                    extension = extension.toLowerCase();

                    for (var i = 0; i < inArrayOfFileExtensions.length; i++ ) {

                              if ( extension == inArrayOfFileExtensions[i] ) {

                                        return true;

                              }

                    }

                    return false;

          }

           

           

          function createFolder (thePath) {

               var theFolder = Folder(thePath);

               if (theFolder.exists == false) {theFolder.create()};

               return(theFolder)

               };

          • 2. Re: I need to Save file add 3 digit sequence almost i finished but i need some help
            sasientry Level 1

            Hi yajiv

             

            Screen Shot 2012-02-20 at 11.49.11.png

             

             

            I need to alert box with all info under the tiff properties

             

            If there is no tiff properties i need to alert(" there is no metada")

             

            Please give me any idea

            • 3. Re: I need to Save file add 3 digit sequence almost i finished but i need some help
              yajiv_viki Level 2

              Hi Sasi,

               

              Sorry to say this, I can't able to understand what your need.

               

              Can you elaborate you procedure in step by step.

               

              I try to do my best....

               

              -yajiv

              • 4. Re: I need to Save file add 3 digit sequence almost i finished but i need some help
                sasientry Level 1

                sure yajiv

                 

                I can explain clearly

                 

                Every files have file info, In that file info there is lot of taps like Description,IPTC

                 

                In Advanced taps i need all information in tiff properties details in  alert windowUntitled.jpg

                • 5. Re: I need to Save file add 3 digit sequence almost i finished but i need some help
                  yajiv_viki Level 2

                  Hi Sasi,

                   

                  As per my understanding, you need to show all information (i.e. height, width & resolution....) about Tiff files.

                   

                  Is it right...!

                   

                  Test this code....

                   

                  var xmpString = app.activeDocument.xmpMetadata.rawData;

                      if( xmpString !=null )

                          alert(xmpString);

                      else

                          alert("There is no Metadata.....!!!")

                   

                   

                  - yajiv

                  1 person found this helpful
                  • 6. Re: I need to Save file add 3 digit sequence almost i finished but i need some help
                    sasientry Level 1

                    Hi yajiv

                     

                    I dont need all raw data detail

                     

                    In Raw data  "xmlns:tiff="http://ns.adobe.com/tiff/1.0/" this string is there i need to process image

                     

                    If this properties is not there i need alert

                     

                    There is to metadata