1 Reply Latest reply on Sep 21, 2015 5:43 PM by Chuck Uebele

    Help with a Script to delete extra paths and spare some

    babbledabble

      Here are a couple scripts that I have so far, but neither work. With the first script I get an error with the "indexOf", and with the second script, it only keeps the second name that is listed in the string. How can I get either of these to work where I can delete all paths except for the multiple ones I want to keep?

       

      function deletepaths()
      {
        if (!documents.length) return false;
      
      
        var doc = activeDocument;
        var save = ["Ex1", "Ex2", "Ex3"];
      
      
        for (var x = 0; x < doc.pathItems.length; x++)
        {
          if (save.indexOf(doc.pathItems[x].name) == -1))
          {
            doc.pathItems[x].remove();
          }
        }
      }
      deletepaths();
      

       

       

      deletepaths();
      function deletepaths(){
      if(!documents.length) return;
      var doc = activeDocument;
      for(var a = doc.pathItems.length-1;a>-1;a--){
      if(doc.pathItems[a].name != ("ex1", "Ex2")) 
           doc.pathItems[a].remove();
        }
      }