title: Windows batch script which removes text in brackets from filenames?
body: <p>I have a bunch of files in a folder which I'd like to copy and rename via a .bat or .vbs script (or similar). The files are named as such:</p>
  
  <pre><code>ABC-DE-(XXX)SomeNameHere.dat
  </code></pre>
  
  <p>I'd like to <strong>copy</strong> the files and rename them, removing the (XXX) part, leaving simply:</p>
  
  <pre><code>ABC-DE-SomeNameHere.dat
  </code></pre>
  
  <p>There is a kind-of similar question answered <a href="https://stackoverflow.com/questions/261515/batch-file-script-to-remove-special-characters-from-filenames-windows">here</a> but I couldn't modify it to work for the above filename pattern, and also it simply renames the files, doesn't copy them.</p>
  
  <p>Any help is much appreciated! Many thanks.</p>
  
  <hr>
  
  <p><strong>Edit:</strong> posting (<em>terrible!</em>) code below. Probably best to ignore this ;_;</p>
  
  <pre><code>@ECHO OFF
  FOR %%F IN ("ABC-DE-(*)*.dat") DO CALL :process "%%F"
  GOTO :EOF
  
  :process
  SET oldname=%1
  SET "newname=%~nx1"
  SET "newname=%newname:*] =%"
  RENAME %oldname% "%newname%"
  </code></pre>