title: IOError: [Errno 2] No such file or directory – os.walk
body: <p>I'm trying to run the following script which simply reads and image and saves it again:</p>
  
  <pre><code>from PIL import Image
  import os
  
  rootdir = '/home/user/Desktop/sample'
  
  for subdir, dirs, files in os.walk(rootdir):
      for file in files:
          im = Image.open(file)
          im.save(file)
  </code></pre>
  
  <p>I however get the following error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "test.py", line 10, in &lt;module&gt;
      im = Image.open(file)
    File "/usr/lib/python2.7/dist-packages/PIL/Image.py", line 2258, in open
      fp = builtins.open(filename, "rb")
  IOError: [Errno 2] No such file or directory: '1.jpg'
  </code></pre>
  
  <p>So, what I'm trying to do is simply read the file <code>1.jpg</code> and save it again, provided that <code>1.jpg</code> is located in the directory.</p>
  
  <p>How can I fix this issue?</p>
  
  <p>Thanks.</p>