title: PowerShell Rename or Delete Thumbs.db Files
body: <p>I am dealing with the Windows bug where you are unable to delete Thumbs.db, as Windows thinks they are "open". </p>
  
  <p>Firstly, I am aware of the possibility of using regedit to allow these to be deleted, but I do not own the network folder so am unable to access the server to do this. However if it helps anyone here is how you would do that:</p>
  
  <pre><code> add a new "Explorer" Registry path:
  
   HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\Explorer\
  
   and then add a DWORD entry called "DisableThumbsDBOnNetworkFolders", and set it to 1.
  </code></pre>
  
  <p>I have found that if I manually rename the Thumbs.db to say "ThisSucks.db" then I can delete the file. I have a ton of these folders with Thumbs in them so I want to write a PS script to rename all of them, or bonus delete.</p>
  
  <p>When I gather the thumbs into a collection, I see the Write-Host print for each file, but when I try to rename I am getting "Cannot rename because file does not exist".</p>
  
  <pre><code>[System.Object[]] $directory = Get-ChildItem -Path $Path -Filter "*.db" -Force -Recurse;
  
  foreach($file in $directory){
      Write-Host -ForegroundColor Green "Found Thumb files";
      Rename-Item $file "StupidFile.db";
  } 
  </code></pre>
  
  <p>Any ideas?</p>