Replacing autodesk_map to bitmaptexture

--- Any help will be much appreciated. i am trying to replace
--- autodesk_map with bitmaptexture for all the materials and multimaterials in scene

--convert function for autodesk map to bitmaptexture
for mp in scenematerials do
(if isProperty mp "Generic_Image" AND classof mp.Generic_Image == Autodesk_Map then
a = mp.generic_image.Parameters_Source as string
grt = trimleft a "BitMap:"
nwmp = Bitmaptexture ()
nwmp.name = mp.Generic_image.name
nwmp.filename = grt
nwmp.coords.realWorldScale = on
nwmp.coords.U_Offset = 0
nwmp.coords.V_Offset = 0
nwmp.coords.U_Tiling = mp.generic_image.Scale_Width
nwmp.coords.V_Tiling = mp.generic_image.Scale_Height
nwmp.coordinates.UVW_Type= 0
nwmp.coordinates.U_Mirror = false
nwmp.coordinates.V_Mirror = false
nwmp.coordinates.U_Tile = true
nwmp.coordinates.V_Tile = true
nwmp.output.output_amount = (mp.generic_image.Parameters_Brightness * 0.01)
nwmp.output.invert = mp.generic_image.Parameters_Invert_Image
nwmp.coords.W_angle = mp.generic_image.Position_Rotation
nwmp.coords.blur = mp.generic_image.Advanced_Parameters_Blur
nwmp.coords.blur_Offset = mp.generic_image.Advanced_Parameters_Blur_Offset
nwmp.filtering = mp.generic_image.Advanced_Parameters_Filtering
nwmp.coordinates.mapChannel = mp.generic_image.Advanced_Parameters_Map_Channel
replaceInstances nwmp mp???)