Daniel Krizian
Daniel Krizian

Reputation: 4716

Load file.q from path containing space character

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""

Upvotes: 3

Views: 3001

Answers (2)

Bogey
Bogey

Reputation: 5724

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"

Upvotes: 1

MdSalih
MdSalih

Reputation: 1996

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.

Upvotes: 3

Related Questions