title: Zipping files in python
body: <p>My program runs smoothly but I want my files from ftp to be zip in my local drive</p>
  <p>The problem is only 1 file is being zipped after calling my main() function</p>
  <p>Here's my code:</p>
  <pre><code>import os
  import upload
  import download
  import zipfile
  import ConfigParser
  import ftputil
  
  def main():
      
      #create a folder Temp on d drive for later use
      path = r'D:\Temp'
      os.mkdir(path)
      
      #parse all the  values at config.ini file
      config = ConfigParser.ConfigParser()
      config.readfp(open('config.ini'))
      server = config.get('main', 'Server')
      username = config.get('main', 'Username')
      password = config.get('main', 'Password')
      uploads = config.get('main', 'Upload folder')
      downloads = config.get('main', 'Download folder')
  
      #connect to ftp
      ftp = ftputil.FTPHost(server, username, password)
  
      dirlist = ftp.listdir(downloads)
      
      for list in dirlist:
          ftp.chdir(downloads)
          target = os.path.join(path, list)
          ftp.download(list, target)
          
      
      #########################################################
      #   THis section is where algo fails but the program run#
      ########################################################
      
      #zipping files
      absolute_path = r'D:\Temp'
      dirlist = os.listdir(absolute_path)
      filepath = r'D:\Temp\project2.zip'
      for list in dirlist:
          get_file = os.path.join(absolute_path, list)
          zip_name = zipfile.ZipFile(filepath, 'w')
          zip_name.write(get_file, 'Project2b\\' + list)
          
                  
          
  
  if __name__ == '__main__':
      print &quot;cannot be&quot;
  </code></pre>