• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

how del The same name of the channel?

Community Beginner ,
Jan 11, 2017 Jan 11, 2017

Copy link to clipboard

Copied

Untitled-1.jpgUntitled-2.jpg

The same name of the channel, is the same pattern. How to keep different channel names, and delete redundant channels with the same name

all channel:1,4,2,1,2,3,1,3,2,4------->channel:1,4,2,3

TOPICS
Actions and scripting

Views

428

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
community guidelines

correct answers 1 Correct answer

Engaged , Jan 11, 2017 Jan 11, 2017

Hi Roychen,

 

Hope this will help... 🙂

var dup=[];
if(app.documents.length>0){
	var docRef = app.activeDocument;
	var mychan = docRef.channels;
	var l=mychan.length;
	while(l--) {
		var mychans=mychan[l].name;            
		if(dup.toString().indexOf (mychans)==-1){
			dup.push(mychan[l].name);
		}
		else{mychan[l].remove();}
	}
}

-yajiv

Votes

Translate

Translate
Adobe
Engaged ,
Jan 11, 2017 Jan 11, 2017

Copy link to clipboard

Copied

Hi Roychen,

 

Hope this will help... 🙂

var dup=[];
if(app.documents.length>0){
	var docRef = app.activeDocument;
	var mychan = docRef.channels;
	var l=mychan.length;
	while(l--) {
		var mychans=mychan[l].name;            
		if(dup.toString().indexOf (mychans)==-1){
			dup.push(mychan[l].name);
		}
		else{mychan[l].remove();}
	}
}

-yajiv

Votes

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
community guidelines
Community Beginner ,
Jan 11, 2017 Jan 11, 2017

Copy link to clipboard

Copied

hi natrev

very good....thx....

Votes

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
community guidelines
Community Beginner ,
Jan 12, 2017 Jan 12, 2017

Copy link to clipboard

Copied

hi natrev..

have some question,if all channel  is 1,2,3,4,4a,3a,1a,2a,1,2 ,run javscript ,result:1a,2a,3a,4a,1,2...lose 3,4

channel name exmple:

1,1a,1b,1c...

2,2a,2b,2c,2d.2e,2f.....

Votes

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
community guidelines
Engaged ,
Jan 12, 2017 Jan 12, 2017

Copy link to clipboard

Copied

Hi Rochan,

 

Try this code.. 🙂

 

var dup=[];
if(app.documents.length>0){
	var docRef = app.activeDocument;
	var mychan = docRef.channels;
	var l=mychan.length;
	while(l--) {
		var mychans=mychan[l].name;
		if(searchStringInArray (mychans, dup)==-1){ 
			dup.push(mychan[l].name);
		}
		else{mychan[l].remove();}
	}
}

function searchStringInArray (str, strArray) {
	for (var j=0; j<strArray.length; j++) {
		if (strArray[j]==str) return j;
	}
	return -1;
}

 

Votes

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
community guidelines
LEGEND ,
Aug 12, 2021 Aug 12, 2021

Copy link to clipboard

Copied

LATEST

 

o = {}, chnnls = [].slice.call(activeDocument.channels); while(chnnls.length)
	!o[nme = (shft = chnnls.shift()).name] ? o[nme] = nme : shft.remove()

 

Votes

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
community guidelines