2 Replies Latest reply on Sep 25, 2015 4:57 AM by ericasp

    Batch remove paths in PSD file

    mariap14286444

      I found the script below which removes a path in a PSD file.

       

      I want to apply this to over 3000 PSD files I have. Actions take too long and crash my computer. I want to be able to choose a folder which it will go through and run the script. If there is no path in the file, I want it to close it and move onto the next one. Actions caused my computer to stop and wait for my go ahead, and when I log errors to file, it keeps the file open which crashes my computer.

       

      #target Photoshop

      main();

      function main(){

      if(!documents.length) return;

      var doc = activeDocument;

      for(var a = doc.pathItems.length-1;a>-1;a--){

      if(doc.pathItems[a].name  != "Ex1") doc.pathItems[a].remove();

          }

      }

       

      Also, can I ask how you run a script through a batch of files? Image processor looks good but doens't look any different to automate > batch to me. It won't let me select the script I want to use, just actions and I can't use those.

       

      Many thanks in advance!

        • 1. Re: Batch remove paths in PSD file
          JJMack Most Valuable Participant

          It will take a long time to process 3000 files with Photoshop automation using either Actions or scripts.

           

          An Actions will only require your interaction if it contains an interactive step(s) or is not well crafted and generate an error.

           

          Actions can not use logic without using a script or plug-in. Actions and Scripts not  well crafted will fail an error will stop the processing being done. 

           

          The image Processor and Image processor pro are batch processors. They have many features that  Automate>Batch does not have.

           

          Both Image processor scripts can be setup to include actions you create to be used in the batch process. 

           

          Actions can use scripts so you could include a script in an action the would delete paths if they exists and do nothing if the paths do not exist.


          That action could be used using Automate.Batch or the Image Processors to batch the action for your 3000 files.

           

          You need to write a script to process  one of your documents the way you want it processed.  Once you have that script you can record it use in an action.  Then you can batch that action with the best suited batch processor.

          1 person found this helpful
          • 2. Re: Batch remove paths in PSD file
            ericasp

            I put together a little script that I'm including in most export action I run. It suppresses any error message dialogs and removes any paths (no matter the naming or amount of paths), alpha channels, layer comps & color samples. However removing guides are done as a separate step in the action.

             

            Create the script and then record an action where you launch the script on a open document. You must have a path in the image when you record it, otherwise the script won't run and the script will not be recorded to the action. Then call the action with "Save & Close" from Automate -> Batch, should do it.

             

             

             

             

            #target photoshop

            var theImage = app.activeDocument;

             

            // supress dialog windows

            displayDialogs = DialogModes.NO

             

            // delete paths

            theImage.pathItems.removeAll();

             

            // delete alphas

            theImage.channels.removeAll();

             

            // delete layercomps

            theImage.layerComps.removeAll();

             

            // delete color samplers

            theImage.colorSamplers.removeAll();