Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python recursively print directory

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

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()
Comment

python script to recursively scan subdirectories

AnsByIsaaco
Comment

PREVIOUS NEXT
Code Example
Python :: numpy random entries not repeat 
Python :: python genap ganjil 
Python :: multithreaded programming in python 
Python :: selenium session id python 
Python :: scrapy access settings from spider 
Python :: mathtext to regular python 
Python :: explode multiple columns pandas 
Python :: python function 
Python :: from future import division 
Python :: loading bar python 
Python :: quotation marks n string 
Python :: python inspect.getsource 
Python :: stdin and stdout python 
Python :: how to install pywhatkit in pycharm 
Python :: @methodclass in python 
Python :: how to know the column number of a dataframe in pandas 
Python :: pure imagination 
Python :: python last non-zero value in a list 
Python :: how to extract column from numpy array 
Python :: list length python 
Python :: pathlib check is file 
Python :: numpy primes 
Python :: python using list as dictionary key 
Python :: pandas fillna by rows 
Python :: dataFrame changed by function 
Python :: sleep your computer python 
Python :: how to import something in python 
Python :: if in one line python 
Python :: list.add in python 
Python :: geopandas read postgis SQL 
ADD CONTENT
Topic
Content
Source link
Name
4+1 =