I'm migrating a BASH script that zips a directory as such:
zip -q -r -X ../$myFolder.zip *.*
to Python, which uses a function such as:
def zipDirectory (srcDir):
(myPath,myLeaf) = os.path.split(srcDir)
myFiles = os.listdir(srcDir)
if len(myFiles) >= 1:
myArchiveDir = os.path.join(myPath, myLeaf + ".zip")
myArchive = zipfile.ZipFile(myArchiveDir, 'w')
for myFile in myFiles:
myArchive.write(os.path.join(srcDir,myFile), myFile)
myArchive.close()
return myArchiveDir
It appears as though the zip archives created by my Python script are a consistently larger than the zip archives from my Bash script (despite the fact that they have exactly the same files). Could somebody enlighten me as to why this is happening? My guess would be maybe the -X
parameter, which "Does not save extra file attributes" doesn't apply in Python. If this is correct, how can I apply it?