79697578

Date: 2025-07-10 20:38:56
Score: 0.5
Natty:
Report link

Managed to get it working by creating a zip file using ZipFile and adding the stuff I wanted in order, and with the directories I ran a for loop over the directory to add all the files inside of it onto new directories I created inside the zip file.

Example code here:

os.chdir("foo\bar")
with ZipFile("foobar.zip", "w", ZIP_STORED) as foo:
    foo.write("mimetype")
    foo.close()
with ZipFile("foobar.zip", "a", ZIP_STORED) as foo:
    for file in os.listdir("directory1"):
        fullPath = os.path.join("directory1", file)
        foo.write(fullPath)

os.replace("foobar.zip", "foo/bar/foobar.epub")
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Ironfort 9