Script to add suffix to spot channel names with sequential numbers?

Explorer ,
Jan 08, 2021

Copy link to clipboard

Copied

Is it possible to ignore the top channel which is usually called 'grey' when in grey mode, and rename all others to have a number as a suffix, so spot channels would be like:

 

Grey

Red 185

Yellow 101

Black

 

and then after running the script it'd look like

 

Grey

Red 185 - 1

Yellow 101 - 2

Black - 3

 

Many thanks in advance 😄

Adobe Community Professional
Correct answer by r-bin | Adobe Community Professional

Try this

 

var ch = app.activeDocument.channels;

var n = 0;

for (var i = 0; i < ch.length; i++)
    {
    if (ch[i].kind != ChannelType.SPOTCOLOR) continue;

    ++n;

    ch[i].name += " - " + n;
    }
TOPICS
Actions and scripting, Mac

Views

59

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Script to add suffix to spot channel names with sequential numbers?

Explorer ,
Jan 08, 2021

Copy link to clipboard

Copied

Is it possible to ignore the top channel which is usually called 'grey' when in grey mode, and rename all others to have a number as a suffix, so spot channels would be like:

 

Grey

Red 185

Yellow 101

Black

 

and then after running the script it'd look like

 

Grey

Red 185 - 1

Yellow 101 - 2

Black - 3

 

Many thanks in advance 😄

Adobe Community Professional
Correct answer by r-bin | Adobe Community Professional

Try this

 

var ch = app.activeDocument.channels;

var n = 0;

for (var i = 0; i < ch.length; i++)
    {
    if (ch[i].kind != ChannelType.SPOTCOLOR) continue;

    ++n;

    ch[i].name += " - " + n;
    }
TOPICS
Actions and scripting, Mac

Views

60

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jan 08, 2021 0
Adobe Community Professional ,
Jan 08, 2021

Copy link to clipboard

Copied

Try this

 

var ch = app.activeDocument.channels;

var n = 0;

for (var i = 0; i < ch.length; i++)
    {
    if (ch[i].kind != ChannelType.SPOTCOLOR) continue;

    ++n;

    ch[i].name += " - " + n;
    }

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 08, 2021 2
Explorer ,
Jan 14, 2021

Copy link to clipboard

Copied

Thank you so much 🙂

If I wanted it as a prefix instead of a suffix how would I go about amending the script?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 14, 2021 0
Adobe Community Professional ,
Jan 14, 2021

Copy link to clipboard

Copied

ch[i].name = n + ' - ' + ch[i].name

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 14, 2021 1