$KMVAR_File_Name doesn't work in execute a shell script macro

I am going to run file -I to check the encode type of a text file.
If I run it in terminal:

Admins-iMac:~ admin$ file -I /Users/admin/Documents/systemtools/Best\ VPN\ in\ 2019\ list.txt
/Users/admin/Documents/systemtools/Best VPN in 2019 list.txt: text/plain; charset=us-ascii

Note the encode type is us-ascii. It works.
It's easy to build this KMM(acro).
Please see the file A in attachment. It's the first version KMM. But I find that if the filename contains space, the KMM will report error. So I use a 'search and replace with regex' macro to escape the space with "\ " in file name(or path).
for example:
the original file path is(you can create a txt file for testing):

/Users/admin/Documents/systemtools/Best VPN in 2019 list.txt

the edited file path is:

/Users/admin/Documents/systemtools/Best\ VPN\ in\ 2019\ list.txt

Please see the file C in attachment. I put this new path in single execute a shell script macro, it works OK. But Please see the file B in attachment.
Screen Shot 2020-03-23 at 14.22.30
I put the new edited path in a variable called path, then send the path to the macron via $KMVAR‗path, it doesn't work.
Hope someone can tell me what's wrong with KMM B.

A nH check encode type of text file v0_Backup_20200321_1526_v0.kmmacros (9.4 KB) B nH check encode type of text file v0.kmmacros (3.1 KB) C nH check encode type of text file v0.kmmacros (2.9 KB)

It would be much easier if you uploaded screenshots of your macros, which can display right in the forum, rather than asking folks to download and import your macros.

When dealing with shell scripts and variables, the first thing that I would always check is that you are putting double-quotes around the variable every time you refer to it.

So rather than this:

$KMVAR‗path

always use this:

"$KMVAR‗path"

Otherwise you risk that files with spaces or other non-alphanumeric characters will cause issues.

If that still doesn't help, my apologies, and please try again with screenshots, perhaps annotated, to help us follow along what you are describing.

2 Likes

You are the man! I add double quotes, now it works great. Thanks.

1 Like

Glad it worked!