python os.walk to save everything in a directory
<p>This script saves the files as <code>"/home/name/main/all my files and stuff"</code>. I want to save it as <code>"main/all my files and stuff"</code>.</p>

<pre><code>def zipit ():
  file_paths = ['/home/name/main/']
  buffer= StringIO.StringIO()
  z= zipfile.ZipFile( buffer, "w" )
  for p in file_paths:
    for dir, subdirs, files in os.walk(p):
      for f in files:
        z.write(os.path.join(dir, f))
  z.close()
  buffer.seek(0)
  final = HttpResponse(buffer.read())
  final['Content-Disposition'] = 'attachment; filename=dbs_custom_library.zip'
  final['Content-Type'] = 'application/x-zip'
  return final
</code></pre>
