title: Python - Sort files in directory and use latest file in code
body: <p>Long time reader, first time poster. I am very new to python and I will try to ask my question properly.</p>
  
  <p>I have posted a snippet of the .py code I am using below. I am attempting to get the latest modified file in the current directory to be listed and then pass it along later in the code.</p>
  
  <p>This is the error I get in my log file when I attempt to run the file:</p>
  
  <pre><code>WindowsError: [Error 2] The system cannot find the file specified: '05-30-2012_1500.wav'
  </code></pre>
  
  <p>So it appears that it is in fact pulling a file from the directory, but that's about it. And actually, the file that it pulls up is not the most recently modified file in that directory.</p>
  
  <pre><code>latest_page = max(os.listdir("/"), key=os.path.getmtime)
  
  cause = channel.FilePlayer.play(latest_page)
  </code></pre>