If he wanted to save the count "8" into a file, what would be the point? If he wanted the last 8 counts of the function, it will always return "8" would it not?
You definitely are cherry pinking and misreading the OP's question and statements. He doesn't want to track the number of times a function or script is called. He want's to track the number of files in a directory over an 8 hour period. He didn't say his reason why, but that is what he wants.
None of us are wanting or trying to argue. We're just trying to clear up some misunderstandings.
Both mine and stevieb's suggestions accomplishes what the OP asked. Yours unfortunately does not.