title: Getting the file name without extension in a Windows Batch Script
body: <p>I'm trying to create a right-click context menu command for compressing JavaScript files with YUI compressor. My ultimate goal is to try to get this to run on a context menu:</p>
  
  <pre><code>java.exe -jar yuicompressor-2.4.2.jar -o &lt;filename&gt;.min.js &lt;filename&gt;.js
  </code></pre>
  
  <p>I know I can use the variable <code>%1</code> to reference the file name being opened. I can't figure out how to get this command into a batch file syntax and haven't been able to find any answers online.</p>
  
  <p><strong>Update:</strong><br>
  Jeremy's answer (+comments) worked. For anyone who stumbles upon this, here is what I had to do:</p>
  
  <p>In the action I created for the JavaScript file, I used this as the command:</p>
  
  <pre><code>minify.bat "%1"
  </code></pre>
  
  <p>Which calls my batch script, which looks like this:</p>
  
  <pre><code>java.exe -jar yuicompressor-2.4.2.jar -o "%~dpn1.min.js" %1
  </code></pre>
  
  <p>For the batch script, keep in mind that the code above assumes the directories for java.exe &amp; yuicompressor are both added to your <code>PATH</code> variables. If you don't add these to your path, you'll have to use the full path for the files.</p>
  
  <p>The sequence <code>%~dpn</code> is used to get:</p>
  
  <ol>
  <li><code>%~d</code> - The drive</li>
  <li><code>%~p</code> - The path</li>
  <li><code>%~n</code> - The file name</li>
  </ol>