File 括号错误
这是我做的这批货File 括号错误,file,batch-file,File,Batch File,这是我做的这批货 @echo off title TXTanimation set dir101=C:\USers\Jake\Desktop\file.bat goto menu echo Lets make a text animation pause set /p dir101=where will the .bat be saved: echo @ECHO OFF > %dir101% :menu echo 0=Edit important inf
@echo off
title TXTanimation
set dir101=C:\USers\Jake\Desktop\file.bat
goto menu
echo Lets make a text animation
pause
set /p dir101=where will the .bat be saved:
echo @ECHO OFF > %dir101%
:menu
echo 0=Edit important information
echo 1=Display .txt
echo 2=Play sound
echo 3=Close sound player
echo 4=Add nessicary wait between .txt
echo 5=Label point
echo 6=Edit variable
echo 7=Goto point
echo 8=Create IF sentence
echo 9=End it
Set /p choose=which one:
If '%choose%'=='0' (
SEt /p title=What is the title
:LOL101
set /p color=what color do you want (type test to experiment with the colors)
If '%color%'=='test' goto tester
goto model
:tester
SEt /p test=Please give hexadecimal number type exit to leave:
if '%test%'=='exit' goto LOL101
color %test%
goto tester
:model
echo title %title% >> %dir101%
echo color %color% >> %dir101%
)
If '%choose%'=='1' (
set /p dir=what is the dir of your .txt:
)
If '%choose%'=='1' (
echo cls >> %dir101%
echo type %dir% >> %dir101%
)
If '%choose%'=='4' (
SEt /p thyme=How much milliseconds 250 is usual:
echo ping 192.168.1.1 -n 1 -w %thyme% >> %dir101%
)
goto menu
If '%choose%'=='9' (
echo Thanks for making
pause
)
它将用于在.bat文件中创建.txt动画。我可以完成它,但我首先需要解决一个问题
问题是它确实如此
echo title%title%>>%dir101%
回显颜色%color%>>%dir101%
即使括号中有你也不太清楚你遇到了什么问题。但是,我发现您的代码存在一个常见问题 您正在设置环境变量,然后尝试使用立即展开来访问该值,所有这些都在用括号括起来的同一代码块中。这无法工作,因为在解析块时会进行扩展,而在执行任何操作之前,整个块都会在一次过程中解析。因此,您最终将获得在块内设置值之前存在的值 解决方案是使用脚本顶部的
SETLOCAL EnableDelayedExpansion
启用延迟扩展。然后使用延迟扩展(!var!
)而不是正常扩展(%var%
)在执行时而不是在解析时获取变量的值
有关更多信息,请在命令提示符下键入
HELP SET
,然后从“最后,已添加对延迟环境变量扩展的支持…”开头的段落开始阅读。愚蠢的问题时间,单引号在.bat文件中还是在cmd中起作用?我只见过双引号。@Bill说到是否statements@JakeInc. 您是说,问题是您的代码正在执行echo title%title%>>%dir101%
和echo color%color%>%dir101%
,即使您的选择没有值“0”?正如dbenham所说,您的实际问题有点不清楚。