2011-10-29 36 views
1

這應該是生成具有不同文件的Web文檔的層次結構,這是因爲我很懶,我做了這個。使用批生成html ..轉義引號

@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 

它也工作,但問題是,我不能刪除/逃脫報價,並給予歇斯底里的時刻。

我嘗試了很多不同的事情。改變類型的回聲,我嘗試了不同的逃生選項,我可以找到www等,但報價仍然存在。

回答

8

你需要逃避所有的CMD保留字符<>|^()&以尖號^

一對夫婦的意見

  1. 沒有逃脫保留字符,如果他們都在裏面引用
  2. 不需要逃避(和)如果他們不是在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