addFile() and cmd.RunCommand

having 3 days of trouble with this. Trying to pass filepaths from an array and add them to cmd object which should then copy them to collection. What seems to happen is that when the cmd is run, each path is added twice - which results in errors that 'file already added to collection' :

Any ideas would be helpful. :upside_down_face:

var groupPathsARR = []
	for (var GROUPkey in tokensOBJ) {
		if (tokensOBJ.hasOwnProperty(GROUPkey) && counter < 10) {
			groupPathsARR = tokensOBJ[GROUPkey];
			
			for (var i = 0; i < groupPathsARR.length; i++) {
				cmd.AddFile(groupPathsARR[i]);
			}
	
			copyVirtuallyToCOll = 1;
			if (copyVirtuallyToCOll) {
				cmd.RunCommand('COPY TO coll://DUPES ');
			}
		}
		counter++;
		// cmd.ClearFiles();
	}```

If you use the cmd which is passed in func, it already contains selected files : either clear it or create a brand new one.