Trying to identify the newest and second newest file in a directory
<p>I am trying to identify the newest and second newest files in a directory.  This is the code I intended to use:</p>

<pre><code>CONFIGS = "/Users/root/dev/config-files/"
allConfigs = sorted(os.listdir(CONFIGS), key=os.path.getctime)
t1 = "%s/%s" % (CONFIGS, allConfigs[-1])
t2 = "%s/%s" % (CONFIGS, allConfigs[-2])
</code></pre>

<p>I am encountering this error, which I can't figure out why:</p>

<pre><code>MBA:dev root$ python
Python 2.7.3 (default, Apr 19 2012, 00:55:09) 
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
&gt;&gt;&gt; import os
&gt;&gt;&gt; CONFIGS = "/Users/root/dev/config-files/"
&gt;&gt;&gt; allConfigs = sorted(os.listdir(CONFIGS), key=os.path.getctime)
Traceback (most recent call last):
  File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/genericpath.py", line 64, in getctime
    return os.stat(filename).st_ctime
OSError: [Errno 2] No such file or directory: 'newest.txt'
&gt;&gt;&gt;
</code></pre>

<p>Anyone have any thoughts?</p>
