title: How can I use PowerShell to `save as...` a different file extension?
body: <p>I'm using the following powershell script to open a few thousand HTML files and "save as..." Word documents. </p>
  
  <pre><code>param([string]$htmpath,[string]$docpath = $docpath)   
  
  $srcfiles = Get-ChildItem $htmPath -filter "*.htm*"
  $saveFormat = [Enum]::Parse([Microsoft.Office.Interop.Word.WdSaveFormat], "wdFormatDocument"); 
  $word = new-object -comobject word.application 
  $word.Visible = $False          
  
  function saveas-document
  {         
      $opendoc = $word.documents.open($doc.FullName);         
      $opendoc.saveas([ref]"$docpath\$doc.FullName.doc", [ref]$saveFormat);         
      $opendoc.close();
  }       
  
  ForEach ($doc in $srcfiles)     
  {
      Write-Host "Processing :" $doc.FullName         
      saveas-document        
      $doc = $null   
  }   
  
  $word.quit(); 
  </code></pre>
  
  <p>The content converts splendidly, but my filename is not as expected.</p>
  
  <p><code>$opendoc.saveas([ref]"$docpath\$doc.FullName.doc", [ref]$saveFormat);</code> results in <code>foo.htm</code> saving as <code>foo.htm.FullName.doc</code> instead of <code>foo.doc</code>. </p>
  
  <p><code>$opendoc.saveas([ref]"$docpath\$doc.BaseName.doc", [ref]$saveFormat);</code> yields <code>foo.htm.BaseName.doc</code></p>
  
  <p>How do I set up a <code>Save As...</code> filename variable equal to a concatenation of <code>BaseName</code> and <code>.doc</code>?</p>