title: Converting all files (.jpg to .png) from a directory in Python
body: <p>I'm trying to convert all files from a directory from .jpg to .png. The name should remain the same, just the format would change.</p>
  
  <p>I've been doing some researches and came to this:</p>
  
  <pre><code>from PIL import Image
  import os
  
  directory = r'D:\PATH'
  
  for filename in os.listdir(directory):
      if filename.endswith(".jpg"):
          im = Image.open(filename)
          im.save('img11.png')
          print(os.path.join(directory, filename))
          continue
      else:
          continue
  </code></pre>
  
  <p>I was expecting the loop to go through all my .jpg files and convert them to .png files. So far I was doing only with 1 name: 'img11.png', I haven't succed to build something able to write the adequate names.</p>
  
  <p>The <code>print(os.path.join(directory, filename))</code> works, it prints all my files but concerning the converting part, it only works for 1 file.</p>
  
  <p>Do you guys have any idea for helping me going through the process?</p>