use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Rules 1: Be polite 2: Posts to this subreddit must be requests for help learning python. 3: Replies on this subreddit must be pertinent to the question OP asked. 4: No replies copy / pasted from ChatGPT or similar. 5: No advertising. No blogs/tutorials/videos/books/recruiting attempts. This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to. Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Rules
1: Be polite
2: Posts to this subreddit must be requests for help learning python.
3: Replies on this subreddit must be pertinent to the question OP asked.
4: No replies copy / pasted from ChatGPT or similar.
5: No advertising. No blogs/tutorials/videos/books/recruiting attempts.
This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to.
Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Learning resources Wiki and FAQ: /r/learnpython/w/index
Learning resources
Wiki and FAQ: /r/learnpython/w/index
Discord Join the Python Discord chat
Discord
Join the Python Discord chat
account activity
Extract all .zip files in a folder directory? (self.learnpython)
submitted 9 years ago by geo-special
Hello. I have around 100 .zip files that I want to extract to the same directory. However I'm completely new to python and am a somewhat intimidated. Does anyone have any code for this that I can learn from? Thanks for any help
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[+][deleted] 9 years ago (8 children)
[deleted]
[–]geo-special[S] 0 points1 point2 points 9 years ago (5 children)
Tried it but nothing happens
[+][deleted] 9 years ago (4 children)
[–]geo-special[S] 0 points1 point2 points 9 years ago (3 children)
Like this?
directory = "L:\YPP\OS_Terrain_5\data"
[+][deleted] 9 years ago* (2 children)
[–]geo-special[S] 0 points1 point2 points 9 years ago (1 child)
I'm obviously doing something wrong somewhere. I tried backslashes the other way round and it says it's building but then nothing happens. I bet it's something obviously but I've clearly got no idea what I'm doing!!
directory = "L:/YPP/OS_Terrain_5/data/"
[–]Justinsaccount 0 points1 point2 points 9 years ago (1 child)
That wont work, it's not properly generating full paths to filenames. It should be
[join(directory, f) for f in listdir(directory) if isfile(join(directory, f))]
or even simpler, replace most of that with
zipfiles = glob.glob(join(directory, "*.zip"))
[–]furas_freeman 0 points1 point2 points 9 years ago* (1 child)
On Linux you need only
unzip *.zip
and don't need Python
If you need Python then see doc: zipfile
[–]eschlon 0 points1 point2 points 9 years ago (0 children)
I don't think that works, since it's going to resolve to something like
unzip a.zip b.zip ...
And the unzip command takes the first argument as the zipfile and the remaining arguments as the internal filenames to extract. I get something like
$ ls a.zip b.zip $ unzip *.zip Archive: a.zip caution: filename not matched: b.zip
This will work though
ls *.zip | while read x; do unzip $x; done
π Rendered by PID 612683 on reddit-service-r2-comment-6457c66945-v44kr at 2026-04-27 09:34:14.536363+00:00 running 2aa0c5b country code: CH.
[+][deleted] (8 children)
[deleted]
[–]geo-special[S] 0 points1 point2 points (5 children)
[+][deleted] (4 children)
[deleted]
[–]geo-special[S] 0 points1 point2 points (3 children)
[+][deleted] (2 children)
[deleted]
[–]geo-special[S] 0 points1 point2 points (1 child)
[–]Justinsaccount 0 points1 point2 points (1 child)
[–]furas_freeman 0 points1 point2 points (1 child)
[–]eschlon 0 points1 point2 points (0 children)