Renumbering Element and Node ID's


Hi,
I'll preface this by saying I'm an absolute beginner in tcl, so sorry if my questions are pretty basic.
I am trying to write a script that will loop through each of my components are renumber the elements and node IDs in line with a certain numbering system. I have managed to figure out the renumbering code via the command.cmf file but I'm having trouble being able to replicate the commands that I've used to select the bolt nodes which will have different IDs.
For example:
*retainmarkselections 1 *createmark components 1 'Part# Back Tophat' *displaycollectorsallbymark 1 'isolateonly' 1 1 *createmark groups 2 *displaycollectorsbymark groups 2 'isolate' 1 1 *retainmarkselections 0 *settopologydisplaytype 1 *createmark elements 1 'displayed' *renumbersolverid elements 1 10100000 1 0 0 0 0 0 *createmark nodes 1 'displayed' *renumbersolverid nodes 1 10100000 1 0 0 0 0 0 *createmark nodes 1 10100318 10100326 10100503 10100520 10101252 10101253 *renumbersolverid nodes 1 10190000 1 0 0 0 0 0 *retainmarkselections 1
The line *createmark nodes 1 10100318 10100326 10100503 10100520 etc is actually selected by going Geom > Points > Select by displayed > Select by geoms > lines > displayed > subtract from selection > save and then is retrieved in the renumber nodes panel by select nodes by geom > points > retrive. This works because all nodes that will be used in bolted connections are fixed points and are not on lines in the geometry. Is there any way to replicate this selection process in the .tcl script?
Ultimately I want to loop through each component by isolating them, each time changing the numbering i.e. 1st component starts on 1010000, 2nd component 1020000 etc or use the built-in hypermesh component ID to number the elements and nodes.
Also, could someone please point me in the direction of some basic tutorials that involve looping in tcl?
Many thanks,
Matt