生成html与批处理 [英] Generating html with batch .. escape quotes
本文介绍了生成html与批处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这应该是使用不同的文件生成一个Web文档的层次结构,这是因为我很懒,我做了这个。
This is supposed to generate the hierarchy to a web document with the different files, it's because I'm lazy I made this.
@echo off
echo.
echo This program will generate the base folder for a new website .. .
pause
md folders
echo > folders/default.html "<html> /* More content */ </html>"
echo > folders/style.css " /* All the standards i always use */ "
echo > folders/javascript.js " /* All the standards i always use */ "
echo.
exit
它也可以工作,但问题是,我无法删除/转义引号这让歇斯底里的时刻虽然如此。
It also work but the problem is, I cannot remove/escape the quotes and that give hysterical moments though.
我尝试了许多不同的事情。改变回声的类型,我尝试了不同的逃脱选项,我可以在www等找到,但报价仍然存在。
I tried many different things. Changing echo with type, I tried the different escape options I could find on www etc., but the quotes still there.
推荐答案
您需要转义所有CMD保留字符
>
|
^
(
)
和&
带有插入符号 ^
。
You need to escape all the CMD reserved characters <
>
|
^
(
)
and &
with a caret ^
.
几条评论
- 如果他们内部引用
- 不需要转义(和),如果它们不在IF或FOR或其他括号块内。
一个更完整的例子是
echo ^<!DOCTYPE HTML PUBLIC^> >index.html
echo ^<html^> >>index.html
echo ^<!-- more content --^> >>index.html
echo ^<!-- you don't need to escape ( ) outside blocks --^> >>index.html
echo ^<!-- don't escape inside quotes "&" --^> >>index.html
echo ^</html^> >>index.html
这篇关于生成html与批处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文