I don't think I need to provide any actual code here but the steps go like this:
void RecurseFolder( scan_folder )
{
for each file in the scan_folder
{
}
for each new_folder in the scan_folder
{
RecurseFolder( new_folder )
}
}
You see the function calls itself again for each sub folder it finds in the root folder, so it works its way through all of your directories in basically a depth first search.
If you've never done anything with recursion before I understand that it can seem a little confusing but it's really quite simple.