I want user to enter a path and then my program should open all txt files in that folder. i wrote my code like this and i have no idea how to tell it to open all the txt files. thanks for your help.
from pywinauto import application
import psutil
import os
def Open_file():
app = application.Application()
path = input("path : ")
DOCs = os.listdir(path)
if len(DOCs) > 0:
for i in os.listdir(path):
if i.endswith('.txt'):
app.start("notepad.exe")
app.Notepad.menu_select("File->Open")
Open_file()
i wrote it like this. it opens notepad but i can't open all the txt files in that folder.
def Open_file():
app = application.Application()
path = input("path : ")
DOCs = os.listdir(path)
absolutePath = os.getcwd()+"/"+path
if len(DOCs) > 0:
for i in os.listdir(path):
if i.endswith('.txt'):
app.start(f"notepad.exe {absolutePath}/{i}")