I am trying to use zipfile to zip several files together into a single .zip file. The files I need to zip are not in the root folder from which the python script runs, so i have to specify the path when adding a file to the zip. The problem is that I end up with a folder structure in the zip file, i really only want each file and not the folders. so..
zip = zipfile.ZipFile('./tmp/afile.zip', 'w')
zip.write('./tmp/file1.txt')
zip.write('./tmp/items/file2.txt')
results in a zip files that extracts to:
.
|
|-tmp
| |file.txt
| |-items
| | file2.txt
Is there any way to just add the files to the "root" of the zip file and not creature the folders?