Skip to main content
Inspiring
October 12, 2018
Question

Free script: Remove Selected

  • October 12, 2018
  • 3 replies
  • 17327 views

Hi all,

I wanted to share a super simple script that creates a checkbox for removing Channels, Paths, Colour Pickers and/or LayerComps allowing a simple interface in case you don't always wish to remove all.

Can someone test on Windows for me

#target photoshop  

//Created by Dale R, for public and commercial use

//global variables

var w = new Window('dialog', 'Batch Remove');

w.preferredSize = [50,100];

w.alignChildren = "left"; // align checkboxes to left

// creating buttons and checkboxes

var ck1 = w.add("CheckBox { text: 'Paths', value: false}");

var ck2 = w.add("CheckBox { text: 'Channels', value: false}");

var ck3 = w.add("CheckBox { text: 'Layer Comps', value: false}");

var ck4 = w.add("CheckBox { text: 'Colour Samplers', value: false}");

var p = w.add ('panel', undefined)

p.alignment = "center";

var btn = p.add('button', undefined, 'Run')

p.add ("button", undefined, "Cancel")

btn.onClick =  function () {

    w.close();

    if (ck1.value == true) {

    app.activeDocument.pathItems.removeAll();   

        }

    if (ck2.value == true) {

        app.activeDocument.channels.removeAll();

        }

    if (ck3.value == true) {

        app.activeDocument.layerComps.removeAll();

        }

    if (ck4.value == true) {

        app.activeDocument.colorSamplers.removeAll();

        }

}

w.center();

w.show();

This topic has been closed for replies.

3 replies

Stephen Marsh
Adobe Expert
October 13, 2018

I hacked the script to include the following options:

 

  • Remove Guides
  • Remove all non-clipping paths

 

 

//https://forums.adobe.com/thread/2546383
//https://forums.adobe.com/message/10675883#10675883

//Added options to remove all paths except clipping paths and to remove all guides

#target photoshop    

//Created by Dale R, for public and commercial use 
//global variables 
var w = new Window('dialog', 'Batch Remove'); 
w.preferredSize = [50,100]; 
w.alignChildren = "left"; // align checkboxes to left 

// creating buttons and checkboxes 
var ck1 = w.add("CheckBox { text: 'Non-Clipping Paths', value: false}"); 
var ck2 = w.add("CheckBox { text: 'Channels', value: false}"); 
var ck3 = w.add("CheckBox { text: 'Layer Comps', value: false}"); 
var ck4 = w.add("CheckBox { text: 'Colour Samplers', value: false}");
var ck5 = w.add("CheckBox { text: 'Guides', value: false}"); 

var p = w.add ('panel', undefined) 
p.alignment = "center"; 
var btn = p.add('button', undefined, 'Run') 
p.add ("button", undefined, "Cancel") 

btn.onClick =  function () { 
    w.close(); 

    if (ck1.value == true) { 
    //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[n];
    if(aP.kind != "PathKind.CLIPPINGPATH" ) { aP.remove() }
}
        } 
    if (ck2.value == true) { 
        app.activeDocument.channels.removeAll(); 
        } 
    if (ck3.value == true) { 
        app.activeDocument.layerComps.removeAll(); 
        } 
    if (ck4.value == true) { 
        app.activeDocument.colorSamplers.removeAll(); 
        }
        if (ck5.value == true) { 
        app.activeDocument.guides.removeAll(); 
        } 
} 
w.center(); 
w.show();

However to provide more flexibility, I would prefer to have options for removing specific PathKinds:

 

  • CLIPPINGPATH
  • NORMALPATH
  • WORKPATH
Known Participant
October 14, 2018

Deleting text sometimes needs

JJMack
Adobe Expert
October 12, 2018

Why would someone want to delete things they work hard to create. The color sampler tool has a clear all button in its interface why do you need an additional way to do that.

JJMack
Stephen Marsh
Adobe Expert
October 12, 2018

Thank you for sharing varDale=undefined

JJ it is a common enough task for some workflows to supply final flattened files to a client without wishing to include all of the “workings” included… However in such a situation I personally would prefer a “silent” approach without an interface as I would be wishing to batch remove the same things every time. As varDale=undefined states the intent is to facilitate clearing various elements with the flexibility to change which elements are cleared each time.

I think that it would be good to have an option to remove all paths and all clipping paths… One may wish to keep the clipping paths, but nothing else.

Another candidate for removal could be the note tool.

JJMack
Adobe Expert
October 13, 2018

A saved jpeg file from a layer document does not have any of your work layers is a flat single layer file that does not support transparency or 16bit color. There is nothing for remove from the jpeg file. And in you work document you would want to selective remove thins like alpha channels  not  remove all channels or all all layer comps etc.  You added then for a reason gloabl remove them is not something most would want to do IMO.

JJMack
Known Participant
October 12, 2018

What is Colour Samplers?

Inspiring
October 12, 2018

When you use the eyedropper tool to see the colour information of the sampled area.

Known Participant
October 12, 2018

I tried to draw a few color blocks, sucked black and then selected it, but did not remove the black color block.