I am making a MapInfo program in MapBasic. I am calling OGR2OGR in order to convert some files. To do this I am generating a batch file and then running it. My code looks something like this:
RunStr = "OGR2OGR -f ""ESRI Shapefile"" """ & ExportFolder & "SHP\"" """ & TableFileName & """ -overwrite -skiperrors"
SHPMaker = ExportFolder & "SHPMaker.bat"
Open File SHPMaker
For Output
Access Write
As #1
Print #1, RunStr
Close File #1
Run Program SHPMaker
My problem is that ExportFolder and TableFileName can potentially include spaces. My questions is how should I go about escaping spaces? I have tried both adding carets (^) before the spaces and putting double quotes around the paths -neither works.
The error I am getting is "Unable to open datasource 'GIS' with the following drivers", followed by a list of available drivers. Obviously it is picking up the "GIS" part from mid-way through the paths and treating it as the data source as you can see below.
The generated BAT file looks something like this:
OGR2OGR -f "ESRI Shapefile" "S:\000 GIS Files\TEST WORKSPACE 2\convert test\Converted\SHP\" "S:\000 GIS Files\TEST WORKSPACE\SiteForm.TAB" -overwrite -skiperrors