Hi there,
Can anyone suggest or tell me why the following works fine:
But using a KM variable does not work:
Hi there,
Can anyone suggest or tell me why the following works fine:
But using a KM variable does not work:
From the KM wiki:
If you are passing a file/folder path in a Keyboard Maestro Variable, then it is best to put the Variable reference in double quotes so that spaces in the path will work, like this:
cat "$KMVAR_File_Path"
The second one fails for the same reason that the shell commands in the Terminal:
path='/Volumes/GoogleDrive/My\ Drive'
cd $path
fails. It fails because the \ is in the variable, and is no longer useful as a quoting. Meanwhile, the space in the variable is still useful for word breaking. So it gets it wrong in both ways, it is effectively equivalent to:
cd '/Volumes/GoogleDrive/My\\' 'Drive'
What you nee is:
test
to /Volumes/GoogleDrive/My Drive
cd "$KMVAR_test" && touch test.text
And note that as discussed in many places, that will still not work if you try to use ~/ in the path. If you want to do that, then you would beed to expand the tilde explicitly:
test
to ~/My Documents
test
with Expand Filter in Path
cd "$KMVAR_test" && touch test.text
Thanks so much for the quick reply, this worked. I was scratching my head for ages over it yesterday.