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?
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.
Sign up to join this communityI 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?
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])