I don't find how to set a null variable in a .bat on windows.
on linux I would do:
var=""
echo $var2/${var3}_brain_mask${var}.nii.gz
and then I have as results
var2/var3_brain_mask.nii.gz
but if I do similar stuff on windows I have:
set var=""
echo %var2%/%var3%_brain_mask%var%.nii.gz
and as results
var2/var3_brain_mask"" .nii.gz
the var variable is set at the beginning of the .bat, changed by the user, and I'ld like to be able to set it as empty variable by default as I do on linux.
does anyone has an idea how to do that ?
答案 0 :(得分:0)
Windows 8.1
上的
只需将开头Windows 10
放在"
var
请注意!
set "var="
echo %var2%/%var3%_brain_mask%var%.nii.gz
和
set var=
两者都有效,但总是使用后者会更好,因为它会确保变量中没有捕获的尾随空格会导致输出出现问题
此外,如上所示,从set "var="
开始,输出将与cmdline
不同。
答案 1 :(得分:0)
在Windows 10上测试:
SET var1= & ECHO 123 %var1% abc
,
SET "var2=" & ECHO 123 %var2% abc
和
ECHO 123 %var3% abc
或123 abc
文件中, .bat
将输出.cmd
。
如果手动输入CMD窗口,则每个输出将为:123 %varN% abc
(其中N
代表1
,2
和3
相应地)
SET var4="" & ECHO 123 %var4% abc
会在123 "" abc
或.bat
文件中输出.cmd
。
但是,当在CMD窗口中手动输入时,输出将为123 %var4% abc
,但是:之后输入ECHO 123 %var4% abc
将输出123 "" abc
。