What is the problem
When I try to run a python script that is suppose to find files in my C drive it returns with an error. I tried python 2.7 and 3.8 (I need python 2.7 so I thought that maybe my python was too old but I tried on the latest version and it still failed)
What is the main goal
I am trying to learn how I can create a function or script in python that returns a file with directory path. The ultimate goal is to create a search function that finds a file (an mp4 type file to be specific) then play that file using os.system or any other module. I am doing this first so I can learn how to create what I am looking for over time. I am hoping to understand this concept first.
What have I tried
I tried looking up a couple of different youtube videos but its hard as the stuff I find is usually more complex than what I am looking for. Here are the videos I saw:
https://www.youtube.com/watch?v=y_BGU-2ZL-Q - This is perfect but the code didn't work for me. (See below)
https://www.youtube.com/watch?v=IWDC9vcBIFQ - This is good but I don't think I need to index or create a gui. So I stopped watching as I wasn't sure how I can apply this to a basic script.
What is the code I am using:
def find(name):
count=0
for root, dirs, files in os.walk('C:\'):
if name in files:
print(root,name)
count+=1
print("We found "+ count+" results")
print("Finish")
input()
try:
s=input("name: ")
find(s)
except:
print("Error")
Pictures of the error (I forgot to add this into my post the first time):