As some of my websites have progressed, the server has become cluttered with files no longer in use be it due to versioning, jquery plugins no longer being used, etc...

I'm thinking about writing a script using grep with some regex but if theres already something that exists, it would make things easier.

Can someone point me in the right direction of a script / program that I can feed a listing of html / php / js files that could loop through them, reading the code and tell me what .php, .js, .jpg, etc... files are included?

The script could look at src='', include(), require(), etc...

I'm not looking for someone to do it for me; just a starting point on how to proceed or if something already exists.