title: Retrieving specific directories using os.walk()
body: <p>I have a set of jobs (<code>job1</code>, <code>job2</code> etc) that runs every hour and after they are completed generate folders (<code>session1</code>, <code>session2</code> etc) which contains the log files. Due to storage limitation, I need a script that can delete the session directories older than a set time limit but also want to specify that it must keeps a specified number of session directories e.g keep the latest 2 sessions, even if they are older than set time limit.</p>
  
  <p>How can I achieve this using python <code>os.walk()</code>? I want to return a list of session dirs to delete <code>sessions_to_delete = []</code></p>
  
  <pre><code>/root    
      /job1             (runs every one hour)    
          /session1
              /*log
          /session2
          /session3
      /job2
          /session1
          /session2
  </code></pre>