Hi
I just made a post with what I thought was a Stata problem,
But for me is a Mata problem.
I would like to get files and directories in a root directory from Mata.
the following code works in most cases, but not when there is a ' in the root directory name, eg:
The ' in the directory name makes the code evaluate `: dir "c:/nhb' which is an empty string and gives an error.
Then `"s folder" files *'"' is printed.
Do anyone know a workaround for this?
Thank you in advance.
I just made a post with what I thought was a Stata problem,
But for me is a Mata problem.
I would like to get files and directories in a root directory from Mata.
the following code works in most cases, but not when there is a ' in the root directory name, eg:
Code:
mata fls = sprintf(`"\`"\`: dir %s files *'"'"', sprintf(`""%s""', "c:/nhb's folder")) . mata fls `"`: dir "c:/nhb's folder" files *'"' . mata st_macroexpand(fls) invalid syntax `"s folder" files *'"'
Then `"s folder" files *'"' is printed.
Do anyone know a workaround for this?
Thank you in advance.
Comment