php has lots of filesystem functions
http://www.php.net/filesystem
you can get a list of files in a directory by using
opendir()
or
glob()
or scandir() (php5 only)
you can read the contents of a file by using one of these
fopen()
file_get_contents()
and php can read files over a network if it has the permissions and its set up right.
when trying to match filenames, or contents in a file, youll want to use the string functions
http://www.php.net/strings
pretty much everything your doing is very straightforward. im sure google will help you find LOTS of examples of what your trying to do.