Well, my post did not address traversing directories. I'd encourage you to try substituting everything but the first line of your outer foreach loop with what I suggested. If you would like further explanation of what I've done, I'll gladly provide it.