From windows command shell how might I merge a single layer from multiple file-gdb's into another file-gdb using ogr2ogr? All input gdb's have identically named feature classes and attribute structures.

pseudo example:

ogr2ogr {input layername} D:\output.gdb x:\incoming\*.gdb

it's the layername part I'm having trouble with.

  • maybe -lco FEATURE_DATASET=NAME?
    – Nathan W
    Mar 26, 2015 at 23:17

1 Answer 1


In windows command line you could:

FOR /D /R %g IN (*.gdb) DO ogr2ogr -update -append -f FileGBD D:\output.gdb x:\incoming\%g input_layername

Just place the input_layername after the input dataset.

/D tells FOR to search for directories and /R asks it to do it recursively.

In a .bat file, replace the '%' with '%%', so %g > %%g

Extended batch file example using a) gdb's wrapped in zipfiles as data source, b) projecting to a new coordinate system, and c) selecting multiple input feature classes:

set ogropt=-f FileGBD --config FGDB_BULK_LOAD YES -t_srs EPSG:3579
set layers=Layer_1 Layer_2 Layer_3

for /r %%g in (x:\incoming\*gdb.zip) do (
    ogr2ogr %ogropt% -update -append output.gdb %%g %layers%
  • This works. Where I went astray was thinking multiple input files were allowed, similar to gdal_merge. Also, much to my delight, input gdb-in-zipfiles work, although with hundreds of apparently harmless Recode UTF-8 errors. Mar 27, 2015 at 17:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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