Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

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 :: get_string python 
Python :: como tornar uma string numa lista 
Python :: examples of function decorators in Python 
Python :: pydrive download file 
Python :: i type nano in python and o get error 
Python :: reate the "soup." This is a beautiful soup object: 
Python :: hwoto neglect if any exception happening in python 
Python :: spacy vietnamese 
Python :: python time modülü 
Python :: site:github.com python ssh 
Python :: access nested set with array params python 
Python :: why static kwyword not in python 
Python :: additon of multiple duration timestamps python 
Python :: how to write a correct python code 
Python :: remove all the valu ein dict exacpt provided key pythn 
Python :: how to wirte something 100 times with python 
Python :: how to get entitys of word using pytho nlp 
Python :: two labels on one axis python 
Python :: new listnode(0) meaning 
Python :: python code for calculating probability of random variable 
Python :: python pygeoip example 
Python :: mask and then fillnan# 
Python :: How to open hyperlink with target=“_blank” in PyQt5 
Python :: python text to speech 
Python :: cache in django 
Python :: Deques in python3 
Python :: what is meant by seasonality_mode in prophet 
Python :: saree 
Python :: py regex if .jpg 
Python :: how i rwrite conditon to create 1 or 0 label from two probability column python 
ADD CONTENT
Topic
Content
Source link
Name
2+6 =