2

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.

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.

tshepang
  • 12,111
  • 21
  • 91
  • 136
MeNoob
  • 21
  • 1
  • 2
  • Possible duplicate of [Escape angle brackets in a Windows command prompt](https://stackoverflow.com/questions/251557/escape-angle-brackets-in-a-windows-command-prompt) – phuclv Sep 29 '18 at 03:08

1 Answers1

9

You need to escape all the CMD reserved characters < > | ^ ( ) and & with a caret ^.

A couple of comments

  1. don't escape the reserved chars if they are inside quotes
  2. don't need to escape ( and ) if they are not in IF or FOR or inside another parentheses block.

a more complete example is

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
PA.
  • 28,486
  • 9
  • 71
  • 95