I agree with previous orator. In case you need your own wheel, let's examine provided code.
- First of all, you need to check for directory _before_ matching against /.nsf/. Is it safe to assume file before actual check?
- Second, I personally dislike the idea to change directory using chdir twice. You can work indtead with full path filenames.
right now I have no time, sorry, but I can give a link to
similar code sample.