Script To Delete Empty Channels?
Script To Delete Empty Channels?
Having some trouble here as I'm new to scripting. Lets say after running a process on a file I'm left with a number of empty Channels. It could be 1 Channel, 2, 5, whatever as it varies. And each channel contained the word Void. Is there a way to write a script that will delete all channels that include the term "Void"? Or possibly just delete any channels which are simply empty?
Script To Delete Empty Channels?
Do you mean the channel name is 'void'? And what do you mean by 'empty channel'. A channel can't normally be empty. It can be all white or all black. But to be empty the channel has to be one of the component channels and the document has to be transparent.
Script To Delete Empty Channels?
What I meant is if unneeded channels were named something like Void 1, Void 2, Void 3, etc. Would there be a way to do a script to select any channel containing the term Void and delete them?
By empty channel (bad choice of terminology on my part), I infer to a channel containing nothing but a white fill. Or possibly better yet, any channel filled with a specific RGB value such as:
R 235
G 235
B 235
So if a channel(s) were filled with those RGB values, they were deleted.
By empty channel (bad choice of terminology on my part), I infer to a channel containing nothing but a white fill. Or possibly better yet, any channel filled with a specific RGB value such as:
R 235
G 235
B 235
So if a channel(s) were filled with those RGB values, they were deleted.
Script To Delete Empty Channels?
Bonjour Colorguy
You can use the search method :
Code: Select alldelVoidChannels();
function delVoidChannels()
{
for(var channelIndex = 0; channelIndex < app.activeDocument.channels.length; channelIndex++)
{
var channelRef = app.activeDocument.channels[channelIndex]
var channelName = channelRef.name;
if(channelName.search("void")!=-1 )
{
channelRef.remove();
channelIndex = channelIndex-1;
}
}
}
You can use the search method :
Code: Select alldelVoidChannels();
function delVoidChannels()
{
for(var channelIndex = 0; channelIndex < app.activeDocument.channels.length; channelIndex++)
{
var channelRef = app.activeDocument.channels[channelIndex]
var channelName = channelRef.name;
if(channelName.search("void")!=-1 )
{
channelRef.remove();
channelIndex = channelIndex-1;
}
}
}
Script To Delete Empty Channels?
Thank you very much for your help! Easily inserted and duplicated a few times within another script to delete channels no longer required.