Skip to content
Robert Hoffmann edited this page Sep 26, 2015 · 3 revisions

How it works

  1. Enter a valid Regexp in the (Search for files) textbox
  2. Choose if you wish to display the used or unused report
  3. Enter a valid Regexp in the (Inside these files) textbox
  4. Click on (In this directory), and browse to where you want to search
    • In the VSIX version, simply right-click the project you wish to parse. The (In this directory) button becomes (Search) and alows you to relaunch a search in case your Regexp didn't match what you like.

Once the directory is selected, all files in that directory and it's sub-directories will be loaded into a (ALL Files) list. We then extract one (Match) list containing the files that match the (Inside these files) Regexp, and another (Inside) list that matches the (Search for files) Regexp.

We then start opening all the files in the (Inside) list one by one, and check if the files contents contains a match for one of the filenames found in the (Match) list. If we get a match, we move that filename to a (Found) list, and at the end of the parsing process do a diff between the (Match) list and the (Found) list.

There can be a lot of parsing going on, but since the application is multithreaded, it's pretty fast even on huge directories.

Features

Once the processing is done you can

  1. Toggle between used & unused list
  2. Double click a file in the list to open the containing directory
  3. Alt click a file in the list and you will see an image preview if it's an image
  4. Select one or multiple files in the list
  5. Right-click the list to access the context menu actions
  • Select All
  • Select Other *Inverts selection
  • Export Selection
    • Allows you to save the selection to a .txt file for later investigation
  • Delete Selection
    • You will be prompted for a confirmation
  • Explore Here *Same as double-clicking on a file in the list
  • Verify Existence (VSIX only)
    • In Solution
    • In Project

Verify Existence: Launches VS (Find in files) and searches for matches on the selected file names as a means of double-checking before deleting. Choose wisely how many files you wish to verify as this launches a case-insensitive Regexp search for all selected file names across your entire project/solution and searches through . filetypes as to be realy sure it didn't miss anything.

Criteria for (Search for files), (Inside these files), (In this directory) is saved after each search and restored on application launch. Like this you don't have to re-enter it on each launch if the defaults are not what you want.

Command line parameters (EXE only)

-p path  (if contains spaces enclose with ")
-r report 0|1
-f find   (Regexp)
-i inside (Regexp)
-s shell t

Like this the application can be integrated with other IDE's like Visual Studio, Eclipse, Zend Studio, NetBeans, IntelliJ IDEA, etc.

Example

Find all instances of images inside .css files in c:\temp\myproject, and show which are not used.

FindUnusedFiles.exe -p "c:\temp\myproject" -r 0 -f "\.(gif|jpg|jpeg|png|bmp)$" -i "\.(css)$"

Toggle registration of shell extension so you can launch the application by right-clicking a folder in the windows explorer

FindUnusedFiles.exe -s t

Notes

The main difference between the VSIX and EXE version, is that the EXE version will load ALL files contained inside a directory, whereas the VSIX version will only load the files declared to be active inside a Visual Studio Project (include/exclude from project). And thus, any excluded files will be completly ignored during the search/parse process.

Also since the VSIX version works with actual Visual Studio Project files, when deleting a file the project will be updated accordingly, whereas the EXE version simply deletes the file from your hard-drive. This can leave you with a yellow (missing file) icon if used on Visual Studio Projects since the EXE version has no way of syncing your Visual Studio Project.

Clone this wiki locally