Q: Locating and opening programs based on a word in python I have a script where a user will input a program to open, and that script will open the program. The way I've done it isn't very efficient and so I'm leading into problems.
If I input "Open chrome", the script starts a search for a file called chrome.exe on your computer and then launches it. This works for a few programs like chrome.exe, steam.exe etc, but there are programs where their exe file is named differently.
For example, "Open word". The script will search for a program named word.exe, but the Microsoft Word exe file is actually named WINWORD.EXE, so the search will fail.
So my question is how can I make this more efficient? I know I could add exceptions and find the directory of the file myself but this would be impractical to do for many programs.
    with sr.Microphone() as source:
        success = False
        print (">")
        audio = r.listen(source)
        try:
            print("Processing...")
            t = r.recognize_google(audio)
            print (": " + t)
        except sr.UnknownValueError:
            print("Unknown input") 
            continue
        except sr.RequestError as e:
            print("An error occured at GAPI\nA common cause is lack of internet connection")
            continue

        if "open" in t:
            t = t.replace("open","")
            t = t.replace(" ","")
            z = t
            speak = "Opening " + z
            t = t + ".exe"
            print (t)

            for a,d,f in os.walk("C:\\"):
                for files in f:
                    if files == t.lower() or files == t.capitalize() or files == t.upper():
                        s.Speak(speak)
                        pat = os.path.join(a,files)
                        print (pat)
                        sp.call([pat])
                        success = True

Edit:
I did some research and found out about something called filename pattern searching. I've been unable get it running, any ideas?
