Here is something recursion to print every file path in the root dir, from here.
import os
def printpath(rootDir):
for lists in os.listdir(rootDir):
path = os.path.join(rootDir, lists)
print(path)
if os.path.isdir(path):
Test2(path)
And here is some 'formula' for recursion, from Eric Lippert:
if (<problem can be solved easily>)
return <easy solution>;
// The problem cannot be solved easily.
Problem smaller1 = <reduce problem to smaller problem>
Result result1 = M(smaller1);
Problem smaller2 = <reduce problem to smaller problem>
Result result2 = M(smaller2);
...
Result finalResult = <combine all results of smaller problem to solve large problem>
return finalResult;
}