2

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.

1 Answer 1

0
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}")
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.