根据文本,创建包含多行回显文本的 .txt 文件失败

Creating a .txt file with multiple echoed lines of text fails depending on the text

我是一名临时编码员,试图制作一个 bat 文件,该文件写入一个包含多行文本的 txt 文件,但由于某种原因无法正常工作。 到目前为止我的代码供参考:

@echo off

(
  Echo;extends "res://Mod Data.gd"
  Echo;
  Echo;func_init():
  Echo;test
  Echo;test
  Echo;test
  Echo;test
  Echo;test
  Echo;test
  Echo;test
  Echo;test
  Echo;test
  Echo;test
  Echo;test
  Echo;test
  Echo;test
  Echo;test
  Echo;test
  Echo;test
  Echo;test
  Echo;test
  Echo;test
) > "Output\custom.txt"
pause

(可能没有必要将所有测试内容都放在这里,但我把它放在那里只是为了以防万一。)

当我尝试 运行 它时,它会立即关闭并且不起作用,但是如果我尝试 运行 它而不使用“func_init():”,它会像魅力。

此外,我通过仅打印“func_init():”制作了另一个 bat 文件来测试它,它也工作得很好,所以我不知道这可能是什么。

Nvm,如果你这样格式化就可以了:

@Echo Off

set "out=Output"

 >  "%out%\test.txt" Echo;extends "res://Mod Data.gd"
 >> "%out%\test.txt" Echo;
 >> "%out%\test.txt" Echo;func_init():
 >> "%out%\test.txt" Echo;test
 >> "%out%\test.txt" Echo;test
 >> "%out%\test.txt" Echo;test
 >> "%out%\test.txt" Echo;test
 >> "%out%\test.txt" Echo;test
 >> "%out%\test.txt" Echo;test
 >> "%out%\test.txt" Echo;test
 >> "%out%\test.txt" Echo;test
 >> "%out%\test.txt" Echo;test
 >> "%out%\test.txt" Echo;test
 >> "%out%\test.txt" Echo;test
 >> "%out%\test.txt" Echo;test
 >> "%out%\test.txt" Echo;test
 >> "%out%\test.txt" Echo;test
 >> "%out%\test.txt" Echo;test
 >> "%out%\test.txt" Echo;test
 >> "%out%\test.txt" Echo;test
 >> "%out%\test.txt" Echo;test
 >> "%out%\test.txt" Echo;test

Batch 不够智能,无法知道 Echo;func_init(): 中的 ) 不是 代码块的末尾,所以现在你的脚本正在中止,因为它认为 : 是语法错误。您可以使用 ^ 字符转义右括号来解决此问题。

@echo off

(
  Echo;extends "res://Mod Data.gd"
  Echo;
  Echo;func_init(^):
  Echo;test
  Echo;test
  Echo;test
  Echo;test
  Echo;test
  Echo;test
  Echo;test
  Echo;test
  Echo;test
  Echo;test
  Echo;test
  Echo;test
  Echo;test
  Echo;test
  Echo;test
  Echo;test
  Echo;test
  Echo;test
  Echo;test
) >"Output\custom.txt"
pause