Need help on a script to convert standard material into another (but keep the diffuse texture map)

Need help on a script to convert standard materials into another (but keep the diffuse texture map)
I want this script to find every standard material in the scene. Keep the diffuse map texture path to then convert the standard material to a "SC2 standard material" (stracraft 2). Once converted put the earlier stored diffuse map texture back in place.

mfor o in geometry do 
(
if classof o.material == VRayMtl do 
	(
 
		tt = Standardmaterial ()
		tt.diffusemap = o.material.texmap_diffuse
 
tt.diffuse = o.material.diffuse
		o.material = tt
	)
if classof o.material == Multimaterial then 
	for m = 1 to o.material.numsubs do
	(
		if classof o.material [m] == VRayMtl do
		(
 
		tt = Standardmaterial ()
		tt.diffusemap = o.material[m].texmap_diffuse
		
tt.diffuse = o.material[m].diffuse
		o.material [m] = tt
		)
	)
 
)
actionMan.executeAction 0 "40807"