8 Replies Latest reply on Jun 4, 2013 9:15 AM by CarlosCanto

    Batch image processing

    Jose M. Ramos Level 2

      Hi: So, I'm looking for a way to automate the task of batch processing files located in different folders, opening, saving and closing them in the same location. (Please see the attached screen capture for the folder structure).

      folders.png

      These files are in the Illustrator format but do not include a PDF preview. This is why I must open them in Ai and save them again with the PDF preview. The tricky part is to drill into the different folders and saving them. There are hundreds of these files.

       

      Someone has suggested that a script might help. I will appreciate any suggestions in the matter. Thanks in advanced.

       

      Jose

        • 1. Re: Batch image processing
          CarlosCanto Adobe Community Professional & MVP

          do you mean, you open it, check Create PDF Compatible File option, and save over with the same file name?

           

          are you a scripter?

          • 2. Re: Batch image processing
            Jose M. Ramos Level 2

            Exactly right! Save over the same file name.

             

            No, I'm not a scripter.

            • 3. Re: Batch image processing
              CarlosCanto Adobe Community Professional & MVP

              how do you want to handle it? one Folder of your choice at a time (ie ANASI35-5-M6-1)?

               

              or

              all files in all folders in the main "images" folder?

               

              either way, ai files only right?

              • 4. Re: Batch image processing
                Jose M. Ramos Level 2

                Hey Carlos,

                Sorry I went off line there for a couple of hours. So, the ideal scenario would be that I would go to Illustrator and run a script that would prompt me to point at a folder (in this case the "Images" folder) and then say, "Find all the Ai files within that folder and any subfolders, open, save and close them in their original locations.

                Does that make any sense?

                • 5. Re: Batch image processing
                  CarlosCanto Adobe Community Professional & MVP

                  no problem, it makes perfect sense, I'll give it a try after work...or someone else may help you before I do.

                  • 6. Re: Batch image processing
                    CarlosCanto Adobe Community Professional & MVP

                    here you go, try it with a folder with a couple of files only to see if it works in your mac.

                     

                    // script.name = makeAiFilesPDFcompatible.jsx; 
                    // script.description = opens and resaves Ai files with PDF compatibility checked (Folder Batch);
                    // script.requirements = none
                    // script.parent = CarlosCanto // 06/4/2013;
                    // script.elegant = false;
                    // script.forumPost = http://forums.adobe.com/thread/1224874?tstart=0
                    
                    
                    var folder = Folder.selectDialog("Select Source Folder..."); // select folder
                    
                    
                    if (folder==null) {
                                        alert("Good Bye");
                    }
                    
                    
                    else {
                        var files = find_files (folder, ['.ai']);
                              var fileCount = files.length; // count them
                    
                    
                              if (fileCount>0) {
                                        for (i=0; i<fileCount; i++) {
                                var idoc = app.open(files[i]);
                                var saveOpts = new IllustratorSaveOptions();
                                saveOpts.pdfCompatible = true;
                                idoc.saveAs( files[i], saveOpts );
                                idoc.close();
                                        }
                            alert(fileCount + ' file(s) processed');
                              }
                              else {
                                        alert("There are no Illustrator files in this folder.");
                              }
                    }
                    
                    // recurse subfolders - Peter Kharel
                    function find_files (dir, mask_array){
                        var arr = [];
                        for (var i = 0; i < mask_array.length; i++){
                            arr = arr.concat (find_files_sub (dir, [], mask_array[i].toUpperCase()));
                        }
                        return arr;
                    }
                    
                    function find_files_sub (dir, array, mask){
                        var f = Folder (dir).getFiles ( '*.*' );
                        for (var i = 0; i < f.length; i++){
                            if (f[i] instanceof Folder){
                                find_files_sub (f[i], array, mask);
                            } else if (f[i].name.substr (-mask.length).toUpperCase() == mask){
                                array.push (f[i]);
                            }
                        }
                        return array;
                    }
                    
                    • 7. Re: Batch image processing
                      Jose M. Ramos Level 2

                      Are you kidding me?!? Carlos, this worked awesome! It only targets Ai files and leaves everything else untouched. Great job. With your permission I'm going to share this in the Indesignsecrets blog as well.

                       

                      Thanks a bunch!

                      Jose

                      • 8. Re: Batch image processing
                        CarlosCanto Adobe Community Professional & MVP

                        you're welcome