converting image name extension from .PNG to .png in Python
<p>I have large set of images with .PNG extension (say image00.PNG). I want to convert it into .png (lower case). I got a script from internet, but am unable to process.</p>

<p>Here's the script:</p>

<pre><code>files = os.listdir(cur_dir)
for filename in files:
    file_ext = os.path.splitext(filename)[1]
    if old_ext == file_ext:
        newfile = filename.replace(old_ext, new_ext)
        os.rename(filename, newfile)
</code></pre>

<p>When I try to run it on the terminal, I get the error:</p>

<pre><code>NameError: name 'filename' is not defined
</code></pre>

<p>What could be the problem?</p>
