3

How to load script file from a path containing spaces?

For example, this works:

\l F:/file.q

Below attempts throw an error:

\l  F:/Folder with spaces/file.q
\l "F:/Folder with spaces/file.q"
\l hsym `$"F:/Folder with spaces/file.q"
system "l "F:/Folder with spaces/file.q""
Daniel Krizian
  • 4,586
  • 4
  • 38
  • 75

2 Answers2

3

Not exactly practical, but if you need to load files with spaces in the path, you can use windows short file names:

So given a script path: F://Folder with spaces/file with spaces.q

Given

  • Folder with spaces gets shortname folder~1
  • script with spaces.q gets shortname filewi~.q

You can load the file as follows in q:

q)system "l F://folder~1/filewi~1.q"
    Hello from a q script with spaces in file name

You can get the short name of a file/folder by listing the directory in command print with /x flag (eg. dir /x)


As in general with this situation in windows, you're likely better off avoiding spaces in a filepath.

MdSalih
  • 1,978
  • 10
  • 16
0

I know this is a very old post, but just had the same issue. Found a solution that works for me:

system "cd c:/your path/with spaces/"
system "l your_script.q"
Bogey
  • 4,926
  • 4
  • 32
  • 57