Search code examples
kdbq-lang

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

Solution

  • 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.