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)

One thought on “PowerShell Script to Search Files Recursively

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">