8 Replies Latest reply: Apr 18, 2008 5:10 AM by Michael L Hale RSS

    Sort Vector Art from Bitmaps

    Skempy Community Member
      Hi,

      I have a folder containing over 2000 eps files and need to separate these into raster images and those containing vectors.

      The script I am using opens each file in turn and uses the first layer name to determine if the file has been rasterised or not. If not then I update some meta data and close and save the file. If the layer name is "layer 1" I assume the file has vector artwork and has been rasterised, I then close the file without saving changes.

      ____________ the script__________

      var samplesFolder = Folder("J:/Extracted_Standing_Artwork/Non_Customer")
      var fileList = samplesFolder.getFiles("*.eps");
      for (var i = 0; i < fileList.length; i++) {
      if (fileList[i] instanceof File) {
      var fileRef = new File(fileList[i]);
      app.open( fileRef, );
      var layer = app.activeDocument.activeLayer.name;
      var filePath = decodeURI(app.activeDocument.path);
      var fileName = decodeURI(app.activeDocument.name);
      if (layer=="Layer 1"){
      app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
      }
      else{
      app.activeDocument.info.author = "Bitmap"
      epsSaveOptions = new EPSSaveOptions()
      app.activeDocument.close(SaveOptions.SAVECHANGES)
      }}}

      __________ end ____________

      The result is raster files in the folder with a very recent modified date and untouched vector files.

      Can anyone please suggest a better way of doing this.
      It is possible to test for the "Rasterize Generic EPS Format" dialog box?
      Can a javascript then "move" the vector files into a new folder to leave just the rasters in the orginal folder.

      Any help would be appreciated.

      Simon Kemp
        • 1. Re: Sort Vector Art from Bitmaps
          Michael L Hale Community Member
          See if this thread helps http://www.ps-scripts.com/bb/viewtopic.php?t=1113.

          It shows how to test for generic eps files

          Mike
          • 2. Re: Sort Vector Art from Bitmaps
            Skempy Community Member
            Thanks for the prompt reply Mike,

            I have used you script from the link given but with mixed success.
            The script will identify a text file with and with the string "Adobe Photoshop" but does not find the string in an eps that does contain it!

            I can see the string if I open the eps in notepad but the script does not see it.

            Any ideas?

            Simon.
            • 3. Re: Sort Vector Art from Bitmaps
              Michael L Hale Community Member
              If you are able send some sample files to mhale18 at comcast.net and I will take a looks at editing the script.

              Mike
              • 4. Re: Sort Vector Art from Bitmaps
                Michael L Hale Community Member
                Here is a slight change to the function. It works correctly with the sample eps you sent.

                function isGenericEPS(file){
                var test = file;
                test.open('r');
                var str = test.read();
                test.close();
                var res = str.search('Adobe Photoshop');
                return res == -1 ? true : false;
                };
                • 5. Re: Sort Vector Art from Bitmaps
                  Skempy Community Member
                  Mike,

                  Thanks for the modified script. It did the trick beautifully. Can I ask you one further favour?

                  Could you explain what each line is doing so I increase my understanding of scripting.

                  Thanks

                  Simon Kemp
                  • 6. Re: Sort Vector Art from Bitmaps
                    Michael L Hale Community Member
                    Line 1 defines the function.

                    line 2 sets the file object from the argument to the var test. This line is not really needed, I could have just used the file argument. It's likely a hold over from a previous edit.

                    Line 3 opens the file in read mode.

                    Line 4 reads the entire file and assigns it to str.

                    Line 5 closes the file for good housekeeping.

                    Line 6 search the string in str for 'Adobe Photoshop' and assigns the result to res. res will either be -1 if not found or the start position in the str if it was found.

                    Line 7 tests the contents of res and either returns true or false. This line could be rewritten as an if statement

                    if( res == -1){
                    res = true;
                    }else{
                    res = false;
                    };
                    return res;

                    Line 8 closes off the function block.

                    Hope that helps
                    • 7. Re: Sort Vector Art from Bitmaps
                      Skempy Community Member
                      Mike,

                      I don't suppose you would know how to do this in a VB script?

                      Simon.
                      • 8. Re: Sort Vector Art from Bitmaps
                        Michael L Hale Community Member
                        I haven't tested this and my VBS is not that strong but this should be close

                        Set objFSO = CreateObject("Scripting.FileSystemObject")
                        Set objFile = objFSO.OpenTextFile("C:\temp\Text.eps", 1)
                        str = objFile.ReadAll
                        objFile.Close
                        pos = InStr(str,"Adobe Photoshop",1)
                        ' if pos is not 0 the the string was not found
                        if pos = 0 then
                        ' do whatever you need to to for generic eps
                        document.write("Generic")
                        else
                        document.write("Raster")
                        end if