1

What is the difference between these 2 pieces of code in a batch file?

set str=!str:%%20= !

and

set str=%str:%%20= %
aschipfl
  • 33,626
  • 12
  • 54
  • 99
Sam
  • 3,479
  • 4
  • 17
  • 17
  • 2
    it'll just take a few seconds if you've searched for `exclamation mark` instead of `!` which almost no search engines support. Duplicates: [Windows batch file syntax using exclamation mark](https://stackoverflow.com/q/22041586/995714), [Difference between %variable% and !variable! in batch file](https://stackoverflow.com/q/14354502/995714) – phuclv Aug 20 '21 at 01:50

1 Answers1

0

Finally, after hours I could find the explanation. According to this page How-to: Escape Characters, Delimiters and Quotes at the Windows command line in the paragraph "Escaping Percents" :

Escaping Exclamation marks When the shell is running in EnableDelayedExpansion mode the ! character is used to denote a variable and so must be escaped (twice) if you wish to treat it as a regular character:

^^!

Sam
  • 3,479
  • 4
  • 17
  • 17
  • 2
    This answer does not match the question, it feels like *»where do you live?«* – *»I am 47«*… – aschipfl Aug 20 '21 at 09:08