title: Python - Renaming all files in a directory using a loop
body: <p>I have a folder with images that are currently named with timestamps. I want to rename all the images in the directory so they are named 'captured(x).jpg' where x is the image number in the directory. </p>
  
  <p>I have been trying to implement different suggestions as advised on this website and other with no luck. Here is my code:</p>
  
  <pre><code>path = '/home/pi/images/'
  i = 0
  for filename in os.listdir(path):
    os.rename(filename, 'captured'+str(i)+'.jpg'
    i = i +1
  </code></pre>
  
  <p>I keep getting an error saying "No such file or directory" for the os.rename line.</p>