Hi Barry,
You say your script worked in the past, but “lately is creating an additional zip file inside the main zip file.”
We cannot guess what the additional zip file is. But you can tell us:
-
what is the name of the unexpected zip file?
-
what is inside it?
-
have you double and triple checked that it actually is unexpected, and not just a zip file that exists in the directory being archived?
Your code:
shutil.make_archive('C:\\temp\\FGDB\\PD_DATA_PROD','zip','C:\\temp\\FGDB')
ZIPFILE = 'C:\\temp\\FGDB\\PD_DATA_PROD.zip'
shutil.copy(ZIPFILE, 'Z:\\Group\\GISServices\\Addressing\\Data')
You are creating your zip file inside the same directory that is being
archived. That is dangerous:
Depending on how the make_archive
function is written, it could create the zip file inside the archive directory and then archive itself.
If it did that, I would consider it a bug in make_archive
. Especially if it previously worked correctly, and then after an upgrade started duplicating the zip inside itself.
By the way, Windows can use forward slashes as the path separator, so you don’t need all those doubled-up backslashes. Here is the same code written more nicely:
shutil.make_archive('C:/temp/FGDB/PD_DATA_PROD','zip','C:/temp/FGDB')
ZIPFILE = 'C:/temp/FGDB/PD_DATA_PROD.zip'
shutil.copy(ZIPFILE, 'Z:/Group/GISServices/Addressing/Data')
I suggest you move the zip file to a different location, say ‘C:/temp’, so that there is no chance that the archiver will duplicate its own archive inside the archive.
P.S. I see that make_archive has a verbose
parameter which would be handy here, so you could see what files were being archived, but it’s been deprecated and is now ignored. Does anyone know why?