1

I have a C:/a/b/c/d and I want to zip the file 'd' only. When I do it in Python using py7zr library with

archive = py7zr.SevenZipFile('C:/a/b/c/d.7z', 'w')
archive.writeall('C:/a/b/c/d')
archive.close()

it works but when i extract the zip, i end up having the whole a/b/c path, instead i want only to zip the current file. Any ideas?

2

1 Answer 1

5

You can do it with

archive = py7zr.SevenZipFile('C:/a/b/c/d.7z', 'w')
archive.writeall('C:/a/b/c/d', 'd')
archive.close()

Then file 'a/b/c/d/a.txt' will be archived as 'd/a.txt' instead of 'a/b/c/d/a.txt'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.