title: How do I escape tilde (~) in batch file on replacing it with a different character?
body: <p>The script can replace certain characters to specified character in file names, but is not working for tilde <code>~</code>.</p>
  
  <p>Below two parts are working perfectly.</p>
  
  <pre><code>@echo off
  setlocal enabledelayedexpansion
  for %%a in (*_*) do (
      set file=%%a
      ren "!file!" "!file:_=A!"
  )
  for %%a in (*-*) do (
      set file=%%a
      ren "!file!" "!file:-=B!"
  )
  </code></pre>
  
  <p>But this part is not working.</p>
  
  <pre><code>for %%a in (*~*) do (
      set file=%%a
      ren "!file!" "!file:~=C!"
  )
  </code></pre>
  
  <p>Why is replacement of <code>~</code> not working and how to solve that?</p>