Let me explain what I am trying to do here. I am trying to make a program where you type in a file name (a song to be exact .mp3) and it will search for it automaticly, without having to type in the directory. So the user types in their song in the Pi terminal, and the program searches through the directories to see if the song is there or not, and if it is, it stores it in a variable (or something similar).
I have been looking around trying to get this to work and I can't. As of now the farthest I've got is this code here,
Code: Select all
import os
basepath = '/home/pi'
def process_dir(dirpath):
print dirpath
for root, dirs, files in os.walk(basepath):
for subdir in dirs:
dirpath = os.path.join(root,subdir)
process_dir(dirpath)
However it doesn't let me search for a specific file, it just displays everything in the /home/pi folder.
Thanks for the help everyone! All help is very much appreciated!
Thanks,
Cody