When I use tools in QGIS they generally work. However, when I use them in batch mode, they generally fail.

The difference is that running once I can save results as a temporary file, but in batch mode I save results to disk, and all my project folder paths have spaces.

I've tested, and the tools I have problems with work fine saving to C:\temp or D:\temp, but as soon as a space appears in the file name or path, they fail.

As an example, the SAGA Raster Difference tool works fine running manually saving to a temporary file. When I run the tool in batch mode with the same inputs, I get the following log output:

Converting outputs
Loading resulting layers

The following layers were not correctly generated.    <<--- ERROR MESSAGE
Difference (A - B)
You can check the log messages to find more information about the execution of the algorithm

Algorithm Raster difference correctly executed...

I've tried adding " or ' around the output file path, but neither has worked. Is there a way to utilise paths with spaces?

(running QGIS 2.18 on Windows 7)

  • 2
    It sounds like it's a problem with SAGA, though spaces can be a bit of an issue as well as punctuation. There is a CMD tool that might help SUBST z: "C:\your path with\spaces" then use Z drive in SAGA. When you're done type SUBST z: /D to remove the drive map. This will work with any drive that doesn't have a current mapping; since the demise of floppy discs I use A: and B: for project substitutions as it's unlikely that I will ever have a floppy disc attached as modern main boards no longer have floppy drive headers. – Michael Stimson Jan 23 at 1:49
  • 2
    Try upgrading to QGIS 3.4.4 -- there's been many related fixes, and 2.18 is no longer supported. – ndawson Jan 23 at 2:38
  • @MichaelStimson your suggestion is detailed enough to make a good answer. – csk Jan 23 at 17:53

The first thing I would try is upgrading to the latest version as ndawson indicates, if you can't update or updating doesn't fix the problem there is a workaround that I use.

Problems with spaces and punctuation still arise fairly frequently on Windows, this is because the path needs to be quoted when parsed but isn't being quoted by the tool that is calling the command. Some formats don't like spaces, for example Esri GRID is a format that has severe restrictions on the length of the path and the existence of non-alphanumeric characters.

Although it's a bit of a hack you can use SUBST in CMD to map your path to a drive letter, avoiding the use of spaces. If you don't like CMD there is a Windows option. Either option requires a drive letter that you're not currently using, A: and B: are usually free on Windows systems due to the legacy of floppy drives which are unlikely to be ever used again as modern mainboards don't have FDD headers to plug one into.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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