Jump to content
  • Advertisement
Sign in to follow this  

Python: Searching through a directory structure?

This topic is 4171 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I want to write a program where the user can enter in a file name and search for that file starting in a root directory and searching through all sub-directories for the file. I know how to do this in MEL, but this is my first time really using Python (about 2 hours in). From what I can figure out, this is kind of what I have so far:
for dirpath, dirnames, filenames in os.walk(root):
    for file in fnmatch.filter(filenames, name):
        print os.path.join(dirpath, file)

I still need to read about how to do user input, but I think that's the basic search function. Any Python experts care to help a beginner?

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!