Pages

Saturday, March 2, 2013

Find Unused Files: Application

Yesterday at work i was cleaning up a project and got frustrated because i wanted to remove all images that are no longer referenced inside CSHTML, CSS, and LESS files ...i couldn't find any soft or plugin that could help me, so got stuck with selecting each image name one by one and then searching through the project to see if i got a match or not ..Grrrrr!

So last night i whipped up a little soft to help with just that.



 
The process was really easy, so unless i missed something, i'm surprised i couldn't find some little program on the web that already did just that !

Anyways here's how it works:
  1. enter a regexp that matches the files you want to match
  2. choose if you want to match if they are used or not used
  3. choose what filetypes you want to search inside, to see if they are referenced in there
  4. select your starting directory
  5. ......processing
 And the simple logic behind it:
  1. load all file names from base directory & all sub-directories
  2. extract file names that match what we are testing for
  3. extract file names that match which files we will be searching in
  4. iterate over each of the files we are searching in
  5. open each file and check if the content contains a match
  6. if so add to a match list
  7. do a diff between match list & all list
That's it.
And since it uses standard regexp as input, you can match pretty much anything in any type of file.

Extras:
* Can be launched via the command line by passing it a directory or file path (be sure to add " around your path if it contains spaces). Like this it's easy to integrate with Visual Studio, Eclipse, Zend Studio, NetBeans, etc.
* Double clicking a path in the visible list will open the directory the file is contained in
* Once file processing is done you can toggle the visible list between used/unused files
* Click export to export the visible list to a text file for later investigation
* Regexp criteria and target directory path is saved after successful search and restored on application launch
* Selecting one or more paths in the visible list and clicking delete, will prompt you if you really want to delete the file(s)

Todo:
* Allow passing regexps via command line
* Allow report generation via command line 

* Create version integrated with VS context menu 


Needs .NET 4 installed to function

DOWNLOAD (180Ko)