title: Python - search through directory trees, rename certain files
body: <p>How do I search through subdirectories in Python to find files that match a pattern? I can do this if I manually change directories and run a script, but I'd like to start at the root directory of this tree and run the script. I can't pull it off. </p>
  
  <p>Here's what I do inside the directory that works like a charm:</p>
  
  <pre><code>for root, subs, files in os.walk("."):
      date = re.search("\w*.-\w*.-\w*.",file)
      date_clean = date.group(0).strip()
      hour = re.search("hr\d", file)
      hour_clean = hour.group(0).strip()
      new_name = "Podcast-" + date_clean + "-" + hour_clean +".mp3"
      print "Changing",file,"to",new_name+"."
      os.rename(file,new_name)
  </code></pre>
  
  <p>This works if I change to the directory and run it, but I'd like to run it from the root directory.</p>
  
  <pre><code>D:\Files
      \Podcasts
         \August
           \Show 1 AUG-12-2013 Portland hr 1.mp3
            Show 2 AUG-12-2013 Portland hr 2.mp3
  </code></pre>
  
  <p>Since I have files for more than one month, I'd like to rename them all
  Podcast-MMM-DD-YYYY-hrX.mp3. I tried using fnmatch.filter, but that only helps me find the directories, not go in them and rename these files.</p>
  
  <p>What am I doing wrong?</p>