title: Creating batch file from shell file
body: <p>I have to convert the following shell file into a batch file:</p>
  
  <pre><code>\#!/bin/bash
  \#
  \# Generates and compiles a lexer or parser and runs it (this means
  \# that the lexer/parser must contain a main method)
  \#
  \# Example usage: antlr4-run.sh Lexer.g4
  
  DIR="$(cd `dirname "${BASH_SOURCE[0]}"` &amp;&amp; pwd)"
  ANTLR_JAR=$DIR/lib/antlr-4.2.2-complete.jar
  BASENAME="${1%.*}"
  OUTDIR=out
  
  echo "Generating..."
  java -jar $ANTLR_JAR $1 -o $OUTDIR || exit 1
  
  echo "Compiling..."
  (cd $OUTDIR; javac -cp .:$ANTLR_JAR ${BASENAME}*.java) || exit 1
  
  \#\# run (try parser first, then lexer, then plain)
  echo "Input (end with ^D):"
  
  if [[ -a $OUTDIR/${BASENAME}Parser.class ]] ; then
        (cd $OUTDIR; java -cp .:$ANTLR_JAR ${BASENAME}Parser) || exit 1 
  elif [[ -a $OUTDIR/${BASENAME}Lexer.class ]] ; then
        (cd $OUTDIR; java -cp .:$ANTLR_JAR ${BASENAME}Lexer) || exit 1 
  elif [[ -a $OUTDIR/${BASENAME}.class ]] ; then
        (cd $OUTDIR; java -cp .:$ANTLR_JAR ${BASENAME}) || exit 1 
  fi
  
  exit 1
  </code></pre>
  
  <p>Could you please help me with give an example for the following line?</p>
  
  <pre><code>DIR="$(cd `dirname "${BASH_SOURCE[0]}"` &amp;&amp; pwd)"
  </code></pre>
  
  <p>I know that I have to define a variable in a batch file with set Directory ="..." for example and that <code>$</code> is a <code>commandoline parameter</code>... but I don't know how to write this line in a batch file :/</p>