1

I am trying to echo a loop function to another file and I need to echo two percent signs to it

What I have:

echo for /l %%x in (1, 1, 100) do echo %%x > main.bat
echo pause >> main.bat

Output:

for /l %x in (1, 1, 100) do echo %x 
pause 
Kep13r
  • 27
  • 4
  • 3
    Try `%%%%` please. – Yunnosch Jul 13 '21 at 06:31
  • 2
    Does this answer your question? [How do I escape %% in a batch file](https://stackoverflow.com/questions/44977892/how-do-i-escape-in-a-batch-file) – Yunnosch Jul 13 '21 at 09:41
  • 1
    Sorry, just found a decent duplicate, after getting lost in not-quite answering ones.... That is why I answered AND THEN close-voted for dupe. – Yunnosch Jul 13 '21 at 09:42
  • 1
    duplicates: [Escape percent in bat file](https://stackoverflow.com/q/13551829/995714), [Ignore percent sign in batch file](https://stackoverflow.com/q/1907057/995714) – phuclv Jul 13 '21 at 09:56

1 Answers1

2

You found out that, because of escaping mechanisms, echo %% gets you one %.
So if you need %% then do echo %%%%.

Yunnosch
  • 26,130
  • 9
  • 42
  • 54