Create clusters using script

I'm sorry, what you describe is a bit difficult to follow not having the data in hand or any graphics representing the data or the file names... I don't understand if you are trying to modify the figures or the data structures.

Please post screen captures illustrating step by step what you would like us to help you do.
Thanks