Answers for "python recursively print directory"

0

python recursively print directory

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

python script to recursively scan subdirectories

AnsByIsaaco
Posted by: Guest on December-24-2020
-1

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 = f.read()
            print "Writing '" + toWrite + "' to" + filePath
            folderOut.write( toWrite )
            f.close()

        folderOut.close()
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