title: Windows BATCH script error - do ( was unexpected at this time
body: <p>I try to run a simple batch script as shown below. Basically I want to visit each sub-directory in a given directory and run a gmake command.</p>
  
  <pre><code>echo %USER_DEF_VAR%
  cd %USER_DEF_VAR%\topLevelDir
  for /D %G in ("%USER_DEF_VAR%\topLevelDir\*") do ( 
  cd %G
  gmake clean
  gmake 
  )
  </code></pre>
  
  <p>If I run this script on a command line, it works fine. But when I put this in a .bat script it throws me an error saying </p>
  
  <blockquote>
    <p>do ( was unexpected at this time.</p>
  </blockquote>
  
  <p>I have tried removing spaces wherever possible  as suggested here - <a href="https://stackoverflow.com/questions/9949579/nested-for-loop-in-batch-file-error-do-was-unexpected-at-this-time">nested For loop in batch file error: Do was unexpected at this time</a></p>
  
  <p>I'm still facing the same issue.</p>