I'm pretty new to python, I'm using this as my second experience to continue my learning. My first project (using pandas for data analysis) will have been tougher than this one but this will be a new arena and I need some help to get started because I don't even know what to search for in any documentation.
I have many folders named for tv shows in one directory. And I have many files, of multiple episodes, of several of those shows, in another directory. An issue would be that each episode is stored into a folder of the same title when I download it. Until now I have been organizing the files manually but it's getting to where automating it would be nice (and a good learning exercise). Is there a way to search the 'Downloads' folder for folders that contain files that contain a string, say 'Homeland', and move that file (episode) into the folder titled "Homeland" that is in the other directory? I would also need to match more than one string per file/folder, like "Game" and "Thrones". Moving them to directories is easy enough, but getting the matching strings is where I'd love some insight. Then my next goal would be to loop over every file in 'Downloads' and sort it into the correct tv show's folder.
folders = 'list of folders in downloads'
#maybe I need to create a list here or a function that creates a list?
source_dir = "C:\Users\Downloads"
destination_dir = "C:\Users\TV Shows"
for folder_names in folders:
if folder_name contains destination_name:
# destination_name will be undefined but this is what i want
source_path = str(source_dir) + str(file_name) + str(.mp4)
destination_path = str(destination_dir) + str(file_name) +
str(.mp4)
shutil.move(source_path, destination_path)
if not:
do nothing
It'll have to be changed because there are some variables that are going to yield errors and there's bad syntax but that's the general idea of what I want.