Answers for "python recursively print directory"


python recursively print directory

for root, subdirs, files in os.walk(rootdir):
Posted by: Guest on January-03-2021

python script to recursively scan subdirectories

Posted by: Guest on December-24-2020

how to scan directory recursively python

import os
import sys

rootdir = sys.argv[1]

for root, subFolders, files in os.walk(rootdir):

    for folder in subFolders:
        outfileName = rootdir + "/" + folder + "/py-outfile.txt" # hardcoded path
        folderOut = open( outfileName, 'w' )
        print "outfileName is " + outfileName

        for file in files:
            filePath = rootdir + '/' + file
            f = open( filePath, 'r' )
            toWrite =
            print "Writing '" + toWrite + "' to" + filePath
            folderOut.write( toWrite )

Posted by: Guest on October-09-2020

Code answers related to "python recursively print directory"

Python Answers by Framework

Browse Popular Code Answers by Language