Howto Delete all files within a folder which contain a certain string in Windows using Powershell


If you want to delete files which contain certain string in a folder, you can use the following powershell command. In this example , i am searching for all files which contain the string _thumb in the folder e:\targetfolder and delete it,

Get-Childitem -path e:\targetfolder -Filter *.jpg -Recurse | where-object {$_.Name -ilike "*_thumb*"} | Remove-Item -Force -WhatIf

//display file to be delete 

Get-Childitem -path e:\targetfolder -Filter *.jpg -Recurse | where-object {$_.Name -ilike "*_thumb*"} | Remove-Item -Force 

//actually delete the files

Comments

Popular posts from this blog

How to disable Trend Micro OfficeScan using cmd.

Fake torrent from www.YayMovies.com .. Beware !!! It is a Scam !!

Zishan Z1 firmware Update and Manual