The texture token <shapename> provides a direct connection between the name of the mesh and the texture name, replacing the name of the 'shape' at render time.
Workflow
Rename the textures to:
main_BlueShape.jpg
main_RedShape.jpg
Add 'main_<shapename>.jpg' to the image name of the file texture that is assigned to both meshes in Maya.
Rename the meshes to 'Red' and 'Blue' and the textures will automatically be replaced.