title: Gunzip all the files present in source directory in Python
body: <p>I have written a code to gunzip all the files present in the source folder. But I want to include the check that if gunzipped file doesn't exist then gunzip it else move to next file.</p>
  
  <pre><code>source_dir = "/Users/path"
  dest_dir = "/Users/path/Documents/path"
  
  
  for src_name in glob.glob(os.path.join(source_dir, '*.gz')):
  
      base = os.path.basename(src_name)
      dest_name = os.path.join(dest_dir, base[:-3])
      with: gzip.open(src_name, 'rb') as infile, open(dest_name, 'wb') as outfile:
              try:
                  for line in infile:
                      print ("outfile: %s" %outfile)
                      if not os.path.exists(dest_name):
                        outfile.write(line)
                        print( "converted: %s" %dest_name) 
  
              except EOFError:
                  print("End of file error occurred.")
  
              except Exception:
                  print("Some error occurred.")
  </code></pre>
  
  <p>I have used <code>os.path.exist</code> to check whether the file exists or not, but it seems like <code>os.path.exist</code> doesn't work here.</p>