8
8
83349 M2018-02-22 08:50:42
cmd/bat
83349 M, 2018-02-22 08:50:42

What is the correct way to use a variable in a command?

for /r "%begindir%" /d %%i in (*) do (
  Set "namePath=%%i"
  IF EXIST %%i\test.js (
        set "namePath=!namePath:\=/!"
        set "namePath=!namePath:%begindir%=!"
        set "namePath=!namePath:/test=!"
 		echo !namePath!
 		run -o "{\"tests\": \"\!namePath\!/**/*_test.js\"}"
    )
)

I need to insert it into the line with the launch
run -o "{\"tests\": \"\!namePath\!/**/*_test.js\"}"
. With the addition of this line, I get !namePath! not the correct path. Without a launch line, echo displays the desired values. I did not understand how to correctly escape the variable here.
This is a continuation of my last question ( https://toster.ru/q/507787).

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
res2001, 2018-02-22
@f1o007

run -o "{\"tests\": \"\!namePath!/**/*_test.js\"}"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question