See thread329-370893 and read it all the way through. This question was about doing something else with every file in every subfolder, but much of the same code given there can be recycled for your purpose.
I say read it ALL, because the original script presented had flaws, corrected in later posts to that thread.
The basic idea is that you must recurse the subfolders in a folder to be sure you reach every file. Using this approach you'll probably end up with a much shorter script. ;-)