in reply to How do I extract a file name from a path string

You should consider solving your problem in a different way. By using the opendir and readdir functions to get the entries in a directory, you automatically have the filename separate from the directory name, and you can do it all without spawning an external process.
  • Comment on Re: How do I extract a file name from a path string