Batch Material Assign

So here is the problem. I receive GIS data in one mile squares. I also receive the images that go on the squares and they are named the same so I know which bitmaps get attached to which geometry.The script I need would look at the geometry I have selected. Then go to a folder that I specify. Find a bitmap of the same name. Put that material in the defuse slot of a new material. Then attach it to the object. Then continue with the other objects in the selection.