[GIS] Can ogr2ogr batch file run in cmd.exe

convertogr2ogrserviceswindows

I have very little experience in dealing with ogr2ogr, and currently I am trying to find out if there is a way I can automate batch conversion of .shp files to KML using windows services schedule.

So far I've got the below script In a .bat file based on what I have found on this site:

for /R %%f in (*.shp) do ogr2ogr -f "KML" %%~dpnf.kml %%f 

I am able to run the batch file and convert successfully in FWTools shell, but windows cmd.exe tells me that 'ogr2ogr' is not recognised as a command. Is there any way I can set it up so that cmd.exe recognises it automatically and just runs the .bat file every time?

Best Answer

Of course. You just need to tell cmd where ogr2ogr lives. This can be done in two ways.

1) Create a batch file to lauch cmd with the correct paths. aka "C:\Program Files (x86)\FWTools2.4.7\bin\setfwenv.bat"

@ECHO OFF
CALL "C:\Program Files (x86)\FWTools2.4.7\bin\setfwenv.bat"
ogr2ogr ...

2) You can add the paths that are set in setfwenv.bat into your system paths

enter image description here