#import OS import os for x in os.listdir(): if x.is_file(): # Prints only text file present in My Folder print(x)