在bat文件中声明变量的方式如下:
set xxx_variant_name=yyyyyyyyyyyy
move D:\abc\efg\test.txt %xxx_variant_name%\test.txt
说明:
01.set 那句是声明变量 xxx_variant_name,并给该变量赋值 yyyyyyyyyyyy
02.使用变量时,需要在前后加上 %
举例:
if not exist NewFolder md NewFolder
set DestFolder=D:\abc\efg
move D:\abc\efg\test.txt %DestFolder%\NewFolder\test.txt
博客介绍了在bat文件中声明和使用变量的方法。声明变量使用set语句,如set xxx_variant_name=yyyyyyyyyyyy;使用变量时需在前后加上%,如move D:\\abc\\efg\\test.txt %xxx_variant_name%\\test.txt,并给出了具体示例。

1938

被折叠的 条评论
为什么被折叠?



