On 2017-05-30 08:45, loial wrote:
I am reading a list of pdf files from a directory which is a symbolic link and
adding them to a zip file.
Issue I have is that the zip files are being added as empty directories rather
than the actual pdf files.
My code is below. Any idea why this happening?
# ZIP pdfs subdirectory if it exists
sourcefile = self._dir + os.sep + "pdfs"
targetname = "pdfs"
if os.path.exists(sourcefile):
zf.write(sourcefile,targetname, compress_type=compression)
for file in os.listdir(sourcefile):
targetname = "pdfs" + os.sep + file
zf.write(sourcefile,targetname, compress_type=compression)
# Close zip file
zf.close()
You're not changing 'sourcefile', it's always the path of the folder.
--
https://mail.python.org/mailman/listinfo/python-list