I'm using python 2.7 and try to archive a directory: the object is to: archive the whole folder's content subject: C:\User\blah\blah\parentfolder
structure:C...parentfolder\ 1.docx
2.xlxs
4.pdf
subfolder\5.pdf
6.txt
Now I know that shutil.make_archive() can zip me the folder, but it turned out to be like this
C:\\User\\blah\\blah\\zipfile_name\\parentfolder\ 1.docx
2.xlxs
4.pdf
subfolder\5.pdf
6.txt
but I want a to skip the parentfolder layer in the zipfile_name folder, that is:(This is where the problem is different, I did learn shutil.make_archive from that question, but as I open the shutil module, I found out that make_archive has four intakes. I didn't know what makes them different and used the four input one, that's where I had my question. The previous one didn't not point out why it used just three inputs, and the other answers were using very complicated self-defined functions or so. The answer I chose in this problem compared and explained the difference, which I really appreciate. As a non-computer science majored, I think this kind of details help a lot of people.)
C:\\User\\blah\\blah\\zipfile_name\\ 1.docx
2.xlxs
4.pdf
subfolder\5.pdf
6.txt
if I use os.path.walk and so on to write every file to zipfile_name, it seems it will be super complicated, as I will need to first 1.list everything in the folder--while:1 file?--write into zip folder while:0 directory?--make_directory , and list all items, and while loop again this process( do until no directory exists in the last directory)
Plus I don't know how to make a directory in a .zip folder. So all this just seems complicated.
So is there a way to change a folder into an archive folder while keeping the folder structure?