#๐Ÿ”’ Extracting members of a zipfile leads to the whole path being saved in the given directory

12 messages ยท Page 1 of 1 (latest)

devout nebula
#

Yeah so I'm trying to extract that .cbz file that you see in the second picture. It's alone nested inside the folder "3". However, when the thread runs, its extractions becomes several nested directories with the zipfile's members at the end. It works how it should in that part, but the nested directories shouldn't happen

def build_issues(file_path):

file_path = os.path.abspath(file_path)

base_path = pathlib.Path(file_path).parent

print("[build_issues] file_path (abs):", file_path)
print("[build_issues] extract to:", base_path)

with ZipFile(file_path,"r") as zObject:
    zObject.extractall(base_path)

print("Done")
return

An example of the filepath:
C:\Users\Nickz\OneDrive\Desktop\Code\website2\flaskr\static\Comics/justice-league-vs-suicide-squad-2016/Issues/4/issue-4.cbz

The difference of / and \ should be fixed when running abspath so that isn't an issue

zealous voidBOT
#

@devout nebula

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

zealous voidBOT
#
Formatting code on Discord

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

For long code samples, you can use our pastebin.

devout nebula
#

I had made a .cbz converter that packs images into a .cbz file, but their names were saved as fullpaths instead of just page1, page2, etc.

#

how do I close thi?

#

this

sharp dune
#

Just wait

devout nebula
#

!close

zealous voidBOT
#
Python help channel closed with !close

This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.