Reading filenames in a directory

I want to write a program which is capable of
- reading filenames in a directory
- sorting filenames and deletes the doubles
So I have an index of files.
I's there somebody who has already written something like this ?

Peter
de_m...@dds.nl