We have hundreds of dgn files which have to be converted to shapefiles. I am trying to use these commands to batch convert all the dgn files in a folder.
for %%f in (*.dgn) do ogr2ogr -f "ESRI Shapefile" ".\point\%~nf.shp" "%%f" -where "OGR_GEOMETRY = 'POINT'" -skipfailures
for %%f in (*.dgn) do ogr2ogr -f "ESRI Shapefile" ".\linestring\%~nf.shp" "%%f" -where "OGR_GEOMETRY = 'LINESTRING'" -skipfailures
for %%f in (*.dgn) do ogr2ogr -f "ESRI Shapefile" ".\polygon\%~nf.shp" "%%f" -where "OGR_GEOMETRY = 'POLYGON'" -skipfailures
But I am getting an error of
"|f" is not recognized as an internal or external command, operable
program or batch file
Could anyone tell me what the problem with this command is?
Update: The problem is with the bat file format. It has to be saved in ANSI & not in other format's. The code given by Zoltan in the answer works perfectly
https://stackoverflow.com/questions/27205097/ansi-unicode-conflict-in-batch-file
Best Answer
If you run it from a batch (.bat) file you have to use double percent marks for '~nf' too:
for %%f in (*.dgn) do ogr2ogr -f "ESRI Shapefile" ".\point\%%~nf.shp" "%%f" -where "OGR_GEOMETRY = 'POINT'" -skipfailures