No, only you can help yourself by doing the homework assigned. If someone else did it for you, then how are you supposed to learn anything?
You didn't even specify a language. However the basic way I would go about this is use the language's built-in method for getting directory names, stuff that into a while loop that terminates when it gets a null value or whatever the return value is when it doesn't find any more directories.
It's up to you if you want to feed all the results into an array, and then loop over the array of the directory tree, searching for whatever it is you're looking for. It's more work, but it would make the program much more readable later, and flexible, but I can see an argument being made for just doing it all at the same time via a set of nested while loops.
The counter bit is easy, just incrementing a counter variable every time you find a match. That's a pretty straight forward if loop.
You're on your own to write the actual code, that's just the basic outline of how I would make such a program.
Does anyone know how to do this?
- input a string that is to be used for matching purposes
- loop through the entire directory tree of your drive
- loop through all the files on each drive
- accumulate a total of all files that contain the input matching string
-display the number of files on the drive that contain the input string using a formatted sentence like:
There are nnn files on the drive that contain the string "xxxxx".- String that was input as postional parameter.
PLEASE HELP ME! It's for my homework!