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

PREVIOUS NEXT
Code Example
Python :: move items from one list to another python 
Python :: how to save an image with the same name after editing in python pillow module 
Python :: pyqt5 keypressevent 
Python :: from django.contrib import messages 
Python :: how to sort a dictionary using pprint module in python 
Python :: reverse range in python 
Python :: django login code 
Python :: convert python float list to 2 digit 
Python :: size of the query process in python BigQuery 
Python :: get number of zero is a row pandas 
Python :: Origin in CORS_ORIGIN_WHITELIST is missing scheme or netloc 
Python :: tqdm every new line 
Python :: python hide input 
Python :: ros python service server 
Python :: flask subdomains 
Python :: split word python 
Python :: pygame tick time 
Python :: compare two dictionaries in python 
Python :: tensorflow adam 
Python :: check if a list contains any item from another list python 
Python :: append value to numpy array 
Python :: norm in python 
Python :: panda search strings in column 
Python :: how to remove an element in a list by index python 
Python :: fork function in python 
Python :: seaborn histplot modify legend 
Python :: multiple bar graph in python 
Python :: Display if the column(s) contain duplicates in the DataFrame 
Python :: access row of dataframe 
Python :: how to find in which directory my python code is running 
ADD CONTENT
Topic
Content
Source link
Name
4+6 =