title: Return Folder path and filename recursively in python
body: <p>How can I return just the folder leafs within the targeted directory when using os.walk in python.</p>
  
  <p>Here is my function:</p>
  
  <pre><code>def get_files(directory):
      directory = os.path.abspath(directory)
      if not os.path.isdir(directory):
          return False
  
      files = []  
      for root, subdirs, files in os.walk(directory):
          for f in files:
              if not f.lower().endswith('.jpg'):
                  continue
  
              print root, f
  
  get_files('C:/Temp')
  </code></pre>
  
  <p>Which returns this:</p>
  
  <pre><code>C:\Temp\images socket.jpg
  C:\Temp\images vexusrollout.jpg
  C:\Temp\newdocs\images utilityrollout.jpg
  C:\Temp\newdocs\images vexushelper.jpg
  C:\Temp\newdocs\images vexusmtl.jpg
  C:\Temp\newdocs\images vexusrollout.jpg
  </code></pre>
  
  <p>I'd prefer it return this:</p>
  
  <pre><code>images socket.jpg
  images vexusrollout.jpg
  newdocs\images utilityrollout.jpg
  newdocs\images vexushelper.jpg
  newdocs\images vexusmtl.jpg
  newdocs\images vexusrollout.jpg
  </code></pre>
  
  <p>The main difference between whatever directory i target for looping through, i don't want that bit to be included in the output. </p>