4

I am using QGIS and I want to eliminate fields from 300 shapefiles.

All layers are loaded and selected.

Is there a way to enable all 300 for simultaneous editing?

1
  • 1
    Which software are you using, what have you tried already? – whyzar Mar 7 '16 at 20:24
4

You can use the following code in the Python Console which iterates through each loaded layer (regardless if they're selected or not) and deletes the field with the name you specify. Just replace field_name with...a field name:

for layer in QgsMapLayerRegistry.instance().mapLayers().values():
    with edit(layer):
        fields = layer.pendingFields()
        idx = layer.fieldNameIndex('field_name') 
        layer.dataProvider().deleteAttributes([idx])
2
  • Thank you, I will use this and report back. Extreme newbie question: "How can I find this post as it gets further down the list...?" – buyukcam Mar 8 '16 at 13:12
  • 1
    @buyukcam - I strongly advise that you take a look at tour guide (don't worry, it's quick!). It helps you understand more how this and other Stack Exchange forums work. You can also find everything that you post (questions/answers/comments etc) in your profile by clicking your avatar icon at the top of the web page next to your repuation amount =) – Joseph Mar 8 '16 at 16:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.