title: Delete files after conversion in Powershell
body: <p>I'm very inexperienced in Powershell - but through trial and error I have managed to get a .doc/.docx to .pdf conversion working well for a specified folder and all subfolders. </p>
  
  <pre><code>$wdFormatPDF = 17
  $word = New-Object -ComObject word.application
  $word.visible = $false
  $fileTypes = "*.docx","*.doc"
  Get-ChildItem -Recurse -path "C:\test-acrobat" -include $fileTypes |
  foreach-object `
  {
   $path =  ($_.fullname).substring(0,($_.FullName).lastindexOf("."))
   "Converting $path to pdf ..."
   $doc = $word.documents.open($_.fullname)
   $doc.saveas( $path, $wdFormatPDF)
   $doc.close()
  }
  $word.Quit()
  </code></pre>
  
  <p>Now I'd like to be able to delete the original .doc/.docx files once they've been converted. On doing some searching I've found what I think would work:</p>
  
  <pre><code>{
    remove-item $fileTypes  # delete file from file-system
  }
  </code></pre>
  
  <p>But I'd rather check than throw in a command to delete files...</p>
  
  <p>Any help is greatly appreciated.
  Philip</p>