Batch Echo的HTML5 - 不导出?

时间:2017-04-18 18:53:55

标签: html5 batch-file echo

Hello Stackoverflow人, 我一直在尝试使用echo批量制作自定义HTML文件。 我现在处于一个不起作用的部分所以我在这里请你帮助我... 这是我的代码:

echo        ^<a href="./About.html"^>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;About^</a^> ^>^>index.html
echo        ^<a href="./support.html"^>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Help^</a^> ^>^>index.html
echo        ^<a href="./security.html"^>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Security^</a^> ^>^>index.html

并且在某种程度上它不会导出到index.html ...我想在这个问题上提供一些帮助,

  • Luseres

1 个答案:

答案 0 :(得分:3)

@ECHO OFF
SETLOCAL
SET "nbsp=^&nbsp;"
(
echo        ^<a href="./About.html"^>%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%About^</a^>
echo        ^<a href="./support.html"^>%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%Help^</a^>
echo        ^<a href="./security.html"^>%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%%nbsp%Security^</a^> 
)>u:index.html
GOTO :EOF

除了评论中指出的&问题,文件名之前的^>^> 将被转义,因为您实际上想要附加到文件中。

通过将变量设置为所需的字符串,您可以避免转义每个&

通过括号echo es并在闭括号后用重定向器重定向输出,可以避免在每一行上指定输出文件。

我使用>作为重定向器来重新创建文件。您可能希望使用>>进行追加。我还为输出文件使用了不同的驱动器。

您也可以使用

>>filename echo ......

通过将重定向细节放在行的开头,它不太可能迷路。

您可以使用

 SET "nbsp2=^&nbsp;^&nbsp;"

或类似内容,以减少%var%所需的echo次数。