Find and remove orphaned files

Front-end development teams are constantly adding and changing asset files such as images, scripts, and stylesheets. As the HTML files morph and change, those assets can become orphaned.

It's good to clean remove files that are no longer in use, but it can be difficult to find them, and to be sure that the file is no longer in use.

So, I created a little script to make that easier!



This allows me to do the following:

$ orphan static/images/legacy/*
File 'checklist.png' appears to be in use.
File 'links_sprite.png' appears to be in use.
File 'sample_results.png' appears to be in use.

$ orphan -d static/images/slideshow/*
slide01.jpg appears to be an orphan.
Delete? [y/n] y
Deleted.
slide02.jpg appears to be an orphan.
Delete? [y/n] y
Deleted.
slide03.jpg appears to be an orphan.
Delete? [y/n] y
Deleted.

comments powered by Disqus