Loop to rename bitmap filename strings

Hi Everyone, let me give you a quick introduction to what has been happening to me.

I love 3D.
I am lazy.
I hate doing repetitive work.

Maxscript sounds like a marvel to do repetitive boring tasks sometimes necessary to handle 3D Asset Library work.

I started dipping my toes in Maxscript a few months ago, and managed to save quite a bit of time in automating everyday tasks.

Due to time constraints I've not delved into materials with maxscript yet (and I am a bit put off by the incomprehensible code that is coming out of the Maxscript listener when I give it a shot.

I need to rename material's textures from a library bought a few months ago with a ton of objects with the exact same texture name, with maps distributed into different folders (one per object - I know, when we started using a renderfarm, all hell broke loose due to the same map names across different objects, so you see where I'm getting at...).

I am trying to do the following operation:

Select an object, copy it's object name string, and putting it in front of the diffuse & normal texture file name (for all objects these are named "mat_c0.jpg"&"mat_n0.jpg")

These need to be renamed to the string "ObjName"+"_c0.jpg"(for the diffuse bitmap) & "ObjName"+"_n0.jpg" (for the normal bitmap).

The materials are Corona Materials, and the normal map has a corona normal node between the bitmap and the slot to correct the color gamma in the bitmap.

So, essentially 1 copy string, 2 pastes and a click for one of each of the 300 objects :)

I tried writing 1st the operation using natural language before trying to write maxscript, to structure the approach, but I am completely lost with the syntax in maxscript materials, especially with corona materials, and here is where I would ask for your help :)

Here goes:

-- Select all objects and apply the same set of procedures in a loop

1. Select all objects

-- Start of loop

2. Select object 1 in selection

a) Query currently selected object name and save in a string called ObjName
b) make currently selected object material name = Mat+"ObjName"
c) query bitmap texture filename in $Obj material slot corona diffuse folder
d) delete 1st 4 characters in the material texture filename string
e) replace start of filename with variable ObjName = "Objname_c0.jpg"
f) rename texture filename to "ObjName".jpg

-- CoronaNormal Node Gamma Correction

g) select object's corona normal node (between coronabitmap with normal map and object's corona material bump slot)
h) click "add gamma to input" checkbox

3. Select next object and go to 2a)
4. Print "Done!"

------------------------------------------------------------
I obviously started by looking at what would show up in the Maxscript Listener while manually doing the operations, 1st to see if I could automate the procedures, but this is what I got:

"
select $10288_k_Lilly_100k_VRAY
rootScene[#SME][#View1][#Diffuse_Texture___CoronaBitmap].Properties.reference.filename = "{A110C7D4-A571-4FB7-8589-5535EE40BA9C}"
rootScene[#SME][#View1][#Normal_Texture___CoronaBitmap].Properties.reference.filename = "{D1F9D41B-53C5-4905-A15E-AA53E2734B9A}"
rootScene[#SME][#View1][#Normal_Texture____CoronaNormal].Properties.reference.addGamma = on
"

From this listener output, I can only make out what is happening on last line in the gamma correction checkbox click, but those weird strings in the 2 1st ones left me totally baffled...

Let me know what you think of this, I am not sure if this is the correct way to project a script, I am sure you will see a lot of issues arising from this :)

Kind regards for your time, thanks in advance!
TH