I would like to add a field to all shp-files in a directory and calculate the area. I tried with the parameter "File" but didn't find a way to conncet this input to the other algorithm/operators.

enter image description here


I too have always wondered how to use the "File" parameter. Instead, remove the directory field and use the Vector layer as your input ("shp-File"):


Save the model with your parameters for your field calculator. Then go back to the Processing Toolbox menu and right-click your model. There should be a "Execute as batch process" option:

Execute as batch process

From the interface, click the button with the ellipsis ("...") and then Select from filesystem:

Batch process menu

Find the directory and hold Ctrl while clicking all the .shp files. This will automatically populate each row in the batch menu. Then hit Run.

(Hint: if you have a lot of shapefiles in your directory, instead of holding Ctrl and clicking through them all, sort it by "Type" which will group all the .shp files together. Then select the first .shp file, hold Shift and select the last .shp in the list.)

Hope this helps!

| improve this answer | |

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.