1import os
2import sys
3
4rootdir = sys.argv[1]
5
6for root, subFolders, files in os.walk(rootdir):
7
8 for folder in subFolders:
9 outfileName = rootdir + "/" + folder + "/py-outfile.txt" # hardcoded path
10 folderOut = open( outfileName, 'w' )
11 print "outfileName is " + outfileName
12
13 for file in files:
14 filePath = rootdir + '/' + file
15 f = open( filePath, 'r' )
16 toWrite = f.read()
17 print "Writing '" + toWrite + "' to" + filePath
18 folderOut.write( toWrite )
19 f.close()
20
21 folderOut.close()
22