I'm trying to zip a directory called test_dicoms
to a zip file named test_dicoms.zip
using the following code:
shutil.make_archive('/home/code/test_dicoms','zip','/home/code/test_dicoms')
The problem is that when I unzip it, all of the files that were in /test_dicoms/
are extracted to /home/code/
instead of the folder /test_dicoms/
and all of it's contained files being extracted to /home/code/
. So /test_dicoms/
has a file called foo.txt
and after I zip and unzip foo.txt
's path is /home/code/foo.txt
as opposed to /home/code/test_dicoms/foo.txt
. How do I fix this? Also, some of the directories I'm working with are very large. Will I need to add anything to my code to make it ZIP64 or is the function smart enough to do that automatically?
Here's what's currently in the archive created:
[gwarner@jazz gwarner]$ unzip -l test_dicoms.zip
Archive: test_dicoms.zip
Length Date Time Name
--------- ---------- ----- ----
93324 09-17-2015 16:05 AAscout_b_000070
93332 09-17-2015 16:05 AAscout_b_000125
93332 09-17-2015 16:05 AAscout_b_000248
question from:https://stackoverflow.com/questions/32640053/compressing-directory-using-shutil-make-archive-while-preserving-directory-str