title: add the condition statement to check directory existence. batch scripting
body: <p>I need to add in a conditional statement to check for a folder so that it can exexute the below script.  Lets say the script is placed in folder <code>c:/temp/A</code> but I want the script to excute and change the file extensions of files  in a another directory <code>d:/xxx/B</code>. If directory B doesnt exists, throw an error and exit.  I tried using if else statement but its says no else statement is allowed.  Please help me out and let me know how it can be done.</p>
  
  <pre><code>@echo off
  setlocal ENABLEDELAYEDEXPANSION
  for %%F in (*.*_error* *.*error_*) do ( set "ext=%%~xF"
  SET "ext=!ext:_error=!"
  ren "%%F" "%%~nF!ext:error_=!"
  )
  </code></pre>