Skip to main content
Known Participant
August 31, 2009
Answered

Path Deletion Script

  • August 31, 2009
  • 2 replies
  • 2105 views

i currently have a script which contains a line for deleting all of the channels in a tif file:

activeDocument.channels.removeAll()

and this works fine.  i would like to add the necessary code to also delete all of the paths in a file.  i tried adding the line: activeDocument.paths.removeAll() but i received an error message.

does anyone know the correct way to do this?  please advise.

thanks.

This topic has been closed for replies.
Correct answer MarkWalsh

John A Horner wrote:

thank you both so much for your replys.  it have incorporated your suggestions and the sript seems to be working fine.

i have one more related question: i notice that in some of the scripts i already have there is a semi-colon at the end of most of the lines but not all.  for example:

activeDocument.flatten();

activeDocument.channels.removeAll()

activeDocument.pathItems.removeAll();

does it make a difference one way or another?

finally, i am new to the forums and saw that i was only able to give 1 correct answer or 2 helpful so i wasn't sure the correct protocol for situations where there are 2 apparantly correct solutions.  but now, even though i have 2 correct solutions, it shows up as only "possibly answered".  is there a way to edit this?  please let me know if there is a proper way to handle this on the forums.  thanks again for everything.

jh

If you are flattening the document first, then the warning about deleting vector masks for the current layer won't apply to you, you are good to removeAll.

From what I remember, adding the ';' at the end of each line is 'proper' javascript, and I believe was once required. It often doesn't matter from what I've seen (I am often lazy and forget/neglect to use it myself) as many scripts will run just fine whether it is there or not. I believe it still is required in certain circumstances, although I am not completely sure what they are.

I don't know how the Adobe system uses it's points, not sure what to tell you on that.

2 replies

Stephen Marsh
Community Expert
Community Expert
February 5, 2021

I just stumbled over this old topic, the following script has "fine tuned" path removal options:

 

Free script: Remove Selected

 

MarkWalsh
Inspiring
August 31, 2009

activeDocument.pathItems.removeAll()

NOTE - this will remove the path used as a mask for the currently selected layer, if one exists. You may want to loop through the collection and check to see if the path is a layer mask before deleting it.
Inspiring
August 31, 2009

If you have CS4 you can do something like this to make sure the activeLayer does not have a vector mask

try{
    activeDocument.activeLayer.vectorMaskDensity;
}catch(e){
    activeDocument.pathItems.removeAll();
}