I am trying to select a field (column) in an attribute table for a shapefile based on whether the name of that field contains a string. Then, I need to either change the name of that selected field or create a new field and populate it with the contents of the selected field. I want to use the Python console because I need to repeat this procedure for 125 shapefiles. However, I am inexperienced with this.
For example, in the following two attribute tables, they both have a field that contains 'P.V.Q./G.P.Q.' but with different names attached. I would like to change the names of all the fields in all my shapefiles that contain 'P.V.Q./G.P.Q.' to read only 'P.V.Q./G.P.Q.'
My pseudo-code is:
For every shapefile in Group:
if(shapefie_Field contains 'P.V.Q./G.P.Q.'):
change field_name to 'P.V.Q./G.P.Q.'
elif(shapefile_Field contains 'Q.S'):
change field_name to 'Q.S'
elif (etc.)
The reason is that I need to join 125 shapefiles together and the attribute fields need to match up.