Script To Delete All Channels Currently Not Active

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: Tom, Kukurykus

Colorguy

Script To Delete All Channels Currently Not Active

Post by Colorguy »

I've been playing around with this one for a while and can't seem to get it. I often work with files that may have 30+ channels by the time I get the desired result. Once complete, I'm only going to be using maybe 5 or 6. So, unlike Layers where Photoshop has a function to delete all invisible Layers, its does not offer that for Channels and its a pain deleting one at a time. So what I've been trying to do is write a script that deletes all Channels that are not turned on. Any ideas is more than appreciated. Thanks!

Professional AI Audio Generation within Adobe Premiere Pro - Download Free Plugin here

larsen67

Script To Delete All Channels Currently Not Active

Post by larsen67 »

Well depending on your document mode this would remove all alphas…

Code: Select allapp.activeDocument.channels.removeAll();

If you are using multi-channel and just want to remove the non-visible then try …

Code: Select all#target photoshop

removeChannels();

function removeChannels() {
   
   var i, doc, count;
   
   doc = app.activeDocument;
   
   count = doc.channels.length;
   
   for ( i = count-1; i >= 0; i-- ) {
      
      if ( doc.channels.visible == false ) { doc.channels.remove(); }
      
   };
      
};
Colorguy

Script To Delete All Channels Currently Not Active

Post by Colorguy »

Thanks for the help. Much appreciated.