SuitUp
SuitUp

Reputation: 3182

How can i extract files using custom names with zipfile module from python?

I want to add suffix to names of my files, for example uuid. How can i extract files using zipfile and pass custom names?

Upvotes: 2

Views: 2428

Answers (2)

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 798676

Use ZipFile.open() to open a read-only file-like to the file data, then copy it to a write-only file with the correct name using shutil.copyfileobj().

Upvotes: 4

Katriel
Katriel

Reputation: 123632

Step 1: Extract the files.

Step 2: Rename them.

Upvotes: 0

Related Questions