File Handling in Python import os path = "C:\\Users\\Miho\\dir" for root, dirs, files in os.walk(path): for file in files: print(file) os.walk( path ): Go through all files and folders under the path os.path.join( root, file ) : Combine root and file str.endswith( ".pdf" ): Return True if str ends with ".pdf" with open("my_file", "r") as file" for line in file: if ('string1' in line.lower()) |('string2' in line.lower()): print(line) f = open("my_file", "r") lines = f.read() f.close(): f = open("my_file", "r") lines = f.read() ...