I think this is not an easy task. Sometimes It could be impossible. There must be a some systematic features in the naming convention of the cells and the nets in order to be able to develop a script to do that.
if you tell us why do you need to do so , maybe someone can get an easier idea to help you .