title: Batch to assign filename with spaces to variable
body: <p>Many apologies if this has been answered but I've searched for a week to get this right and to no avail.  I'm trying to create a batch file that looks in a folder for a specific file ext (there will only ever be one), assigns the name of that file to a variable, and then renames the file based on the variable name to a new name.  </p>
  
  <p>What I have so far:</p>
  
  <pre><code>for /F %%x in ('dir /b *.html') do set "FileName=%%x"
  echo %FileName%
  ren %FileName% test.html
  </code></pre>
  
  <p>Because each filename is going to have spaces in it, this solution will only assign the first word of the filename to <code>%FileName%</code> and thus the rename line will not work because it won't find a filename in the folder with <code>&lt;&lt;FirstWordofFilename&gt;&gt;.html</code></p>
  
  <p>My question is, how do I assign a name with spaces in it to a variable?</p>
  
  <p>Again, apologies if this has been answered, I really couldn't find it anywhere despite it having to be a common problem.</p>
  
  <p>Any help would be wonderful.</p>
  
  <p>Thanks!</p>