How can I zip all folders starting with data_
in Python using zipfile?
Asked
Active
Viewed 33 times
0
![](../../users/profiles/6622587.webp)
eyllanesc
- 190,383
- 15
- 87
- 142
![](../../users/profiles/10057504.webp)
Leonard Niehaus
- 370
- 2
- 13
-
What have you tried till now? – PySaad Aug 25 '19 at 04:35
-
I've only figured out how to zip a single dir or multiple. But I cant figure out how to "data_*" zip dirs – Leonard Niehaus Aug 25 '19 at 04:36
-
Share your code – PySaad Aug 25 '19 at 04:36
-
I've used this example: https://stackoverflow.com/questions/1855095/how-to-create-a-zip-archive-of-a-directory – Leonard Niehaus Aug 25 '19 at 04:39
-
For us to solve your given problem, you need to show what you have tried till now. You can write code which shows that this code zips my folders but how to get folders with data_ So please write code over here – PySaad Aug 25 '19 at 04:43
-
use glob pkg...glob.glob('data_*') gives a list of your desired folders..then loop over them and zip them 1 by 1 – Derek Eden Aug 25 '19 at 06:01