Skip to main content
Inspiring
June 17, 2019
Question

action delete path with any name

  • June 17, 2019
  • 2 replies
  • 1719 views

I have to do a simple action to delete the clipping paths in many photos, the problem is that the tracks have different names in the various photos and the action then always crashes. How can I do?

This topic has been closed for replies.

2 replies

Stephen Marsh
Adobe Expert
June 29, 2020
Stephen Marsh
Adobe Expert
June 17, 2019

This script will remove all path types (unsaved work paths, saved paths, clipping paths and vector shape paths):

 

 

// remove ALL path types

if (documents.length > 0) {
docRef = activeDocument;
for (var i = docRef.pathItems.length-1 ; i >=0 ; i--) {
$.writeln(docRef.pathItems.kind);
docRef.pathItems.remove();
}
} else {
alert("There must be at least one open document to run this script!");
}

 

 

This script removes all paths except clipping paths:

 

 

//https://www.hilfdirselbst.ch/foren/Script_um_Pfade_zu_l%F6schen_P372902.html
var myPath = activeDocument.pathItems;
for (n = myPath.length-1; n>-1; n--)
{ aP = myPath;
if(aP.kind != "PathKind.CLIPPINGPATH" ) { aP.remove() }
}

 

 

 

This script also removes all paths except clipping paths:

 

 

//https://feedback.photoshop.com/photoshop_family/topics/multiple_path_deletion_please

#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.kind != PathKind.CLIPPINGPATH) doc.pathItems.remove();

    }

}

 

 

NOTE: You should be able to swap out the "if" line code that read as " != " with " === " to only delete clipping paths, such as:

 

 

//https://feedback.photoshop.com/photoshop_family/topics/multiple_path_deletion_please
#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.kind === PathKind.CLIPPINGPATH) doc.pathItems.remove(); // != changed to ===
    }
}

 

 

One could then record the execution of this script into an action, then apply the action via Batch Action/Image Processor/Image Processor Pro/Picture Processor scripts to multiple files (take care, perhaps backup first).

Jiweeon
Known Participant
June 29, 2020

How do you make a .jsx file with these scripts? Is there a program or notepad that I need to be using in order to save these scripts out properly so Photoshop can use them? 

Stephen Marsh
Adobe Expert
June 29, 2020