I have a folder with 150 .gml (addressbase) files I need to upload to my postGIS/postgres database. After the first gml is uploaded, the rest will be appended to it to form a single table. However I don't know how to make ogr2ogr iterate through each file… currently I'm having to upload/append each cml induvidually.
My code to convert the first gml:
ogr2ogr -update -append -f "PostgreSQL" PG:"host=localhost port=5432 dbname=testdb user=admin password=password" -lco SCHEMA=test_schema "D:\path to folder\File1.gml" -progress -lco OVERWRITE=YES
and my code to append each subsequent gml to the first:
ogr2ogr -update -append -f "PostgreSQL" PG:"host=localhost port=5432 dbname=testdb user=admin password=password active_schema=test_schema" "D:\path to folder\File2.gml" -progress
This works fine but I don't want to do this another 148 times, changing File2 to File3 each time etc…
The GMLs contain point features. For use with postgis and qgis.
Best Answer
Looking at your examples, I assume you are working on a Windows machine. Try the following:
.bat
or.cmd
extension, say "D:\Work\do_149.cmd".The double quotes around "%dirgml%\*.gml" and "%%G" let you work with directory name and filename that have spaces in them e.g., "D:\Project Frosty\My Snowmobile.gml".