My First Project

Hello everyone,

Maybe I’m jumping the gun here as I’m only about 50% of the way through python mastery. As much as I like Mosh and think he’s a great teacher, I need to mix things up a bit. I decided to stretch my mind and fingers and try to throw at least the beginning of a project together.

Project - I’d like to make a program that scans a folder for names of files and then makes “tags” of the files. My idea is using this to scan my photos, music and videos generating “tags” that you can then use to make searching for something specific easier.

So far I got this to search a folder;

import os

path = input("Enter Path ")
files = os.listdir(path)
Tag = ({})

for f in files:

I’m not sure how to store the names and then turn those into “tags” I’ve done a google search but not coming up with much. Not looking for the exact answer here but to be pointed in the right direction. I’m honesty not sure what this type of thing would be called in python, which makes it harder to search for. Maybe this is too advanced for a newb such as myself? Or maybe I’m over thinking it. XD

Cool that you’re already starting a project as you learn. You will learn much faster like that.

What do you want the tags look like though?

At the moment just a folder I threw a couple random photos in. I’ve been able to scan a folder and print the file names. Then I fell down a rabbit hole and am trying to throw while loops in there. I’m not sure this is correct but I also made this into it’s own function. I believe this is how functions are meant to be used on some level? Anyways, I broke it while messing with it, but this is where I’m at -

print("Enter ‘end’ to stop program. ")
path = input("Enter Path ")
files = os.listdir(path)
print(files)
search = input("Search ")

def search():
    key == True
    while key is True:
        if search in files:
            print(search)
        elif search is not files:
            print("File Not Found")
        elif search == "end":
            key: bool = False

Good progress, but where are you calling the function? Make sure you’re calling the function somewhere:

def search(key, files):
    if key in files:
        print(search)
    else:
        print("File Not Found")
    

path = input("Enter Path ")
files = os.listdir(path)
print(files)
searchKey = input("Search ")

search(searchKey, files) #Call the function or it won't ever run.