Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

search all files for text in directory

findstr /s /i .TextToSearchForWithWildcards. *.txt

/s --> Search all subfolders as well
/i --> Not case sensitive
Comment

# find all text files in directory or any type of files in directory

# find all text files in directory or any type of files in directory
import glob, os
os.chdir("/mydir")
for file in glob.glob("*.txt"):
    print(file)
    
or

import os
for file in os.listdir("/mydir"):
    if file.endswith(".txt"):
        print(os.path.join("/mydir", file))
        
or

import glob
glob.glob('./*.txt')


for root, dirs, files in os.walk(directory):
    for file in files:
        if file.endswith('.txt'):
            print(file)
Comment

PREVIOUS NEXT
Code Example
Python :: list of pdf download python selenium 
Python :: discord python bot input 
Python :: how to take input as an integer in python 
Python :: adjoint of 3x3 matrix in python 
Python :: how to show all rows whith a unique value in a column 
Python :: selenium send text in p html tag 
Python :: Remove Brackets from List Using for loop 
Python :: get token eth balance python 
Python :: python special methods list 
Python :: lsit to dataframe 
Python :: pygame getting your charecter to jump 
Python :: opencv2.3 
Python :: merge csv files into one 
Python :: make python present number in sciencetifc 
Python :: gitlab ci deploy key 
Python :: Repetition in code for routes in Flask (or Bottle) 
Python :: Flask error: werkzeug.routing.BuildError 
Python :: penis command discord.py 
Python :: ax pie rounding 
Python :: ring Create Lists 
Python :: easy ocr python pypi 
Python :: django bring specific values first 
Python :: pairplot seaborn legend best position set 
Python :: tkinter trig calculator 
Python :: idiomatic python 
Python :: I want to add a new column to the DataFrame containing only the month of the measurement 
Python :: legend outside subplot not displayed 
Python :: login system read data python 
Python :: prime numbers from 1 to 100 in python 
Python :: alexa in python 
ADD CONTENT
Topic
Content
Source link
Name
2+4 =