Tag Archives: powershell

PowerShell Script to Search Files Recursively

We had a requirement to find all images within our solution folder and check which all of them are being referenced. This was mainly to identify the unused images and cleanup the deployment.

Looked like a good place to use Windows PowerShell and this is what I came up with. From the current folder, it looks all subfolders and builds a list of files. Then, a list of images is made similarly. Then a loop runs to find if any of these images are present in file content.

There are couple of known limitations to this script
1. The script doesn’t look at the actual path of the referenced file, just looks for file name
2. There is no filter for file-type when we get list of files (deliberately left out, please add)