# I need a script to extract a file with wildcards from 'all' zipfiles in a folder...

**URL:** <https://boards.straightdope.com/t/i-need-a-script-to-extract-a-file-with-wildcards-from-all-zipfiles-in-a-folder/468405>\
**Category:** Factual Questions\
**Created:** [October 17, 2008, 4:54pm UTC](https://boards.straightdope.com/t/i-need-a-script-to-extract-a-file-with-wildcards-from-all-zipfiles-in-a-folder/468405 "2008-10-17T16:54:47Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lobsang](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/lobsang/32/4067_2.png) [@Lobsang](https://boards.straightdope.com/u/Lobsang)\
**Post date:** [October 17, 2008, 4:54pm UTC](https://boards.straightdope.com/t/i-need-a-script-to-extract-a-file-with-wildcards-from-all-zipfiles-in-a-folder/468405/1 "2008-10-17T16:54:47Z")

</div>

and subfolders.  
I have several hundred zipfiles (nearly a year’s worth) from which I need to extract files that fit the following wildcard: _wg_.odb

I know a bit about scripting but I need this fast and I’d probably spend all day trying to figure it out.

If you can help I’ll be eternally in your debt. Well, actually, no I won’t. But I will be greatful 🙂

---

<div class="post-metadata">

**Author:** ![Lobsang](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/lobsang/32/4067_2.png) [@Lobsang](https://boards.straightdope.com/u/Lobsang)\
**Post date:** [October 17, 2008, 4:59pm UTC](https://boards.straightdope.com/t/i-need-a-script-to-extract-a-file-with-wildcards-from-all-zipfiles-in-a-folder/468405/2 "2008-10-17T16:59:43Z")

</div>

Actually. I might be able to get away with using windows’ ability to search within zipfiles… It’s running now. Only time will tell whether I will actually be able to do anything with the results. Last time I did this I got ‘unable to read from source’ errors when trying to copy the files or zip them up into one zipfile.

---

<div class="post-metadata">

**Author:** ![Lobsang](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/lobsang/32/4067_2.png) [@Lobsang](https://boards.straightdope.com/u/Lobsang)\
**Post date:** [October 17, 2008, 5:13pm UTC](https://boards.straightdope.com/t/i-need-a-script-to-extract-a-file-with-wildcards-from-all-zipfiles-in-a-folder/468405/3 "2008-10-17T17:13:56Z")

</div>

Nope. Can’t do anything useful with the search results (Nice one _Windows_ give me the ability to search within zipfiles but don’t let me do anything with the results!!)

---

<div class="post-metadata">

**Author:** ![J\_Cubed](https://avatars.discourse-cdn.com/v4/letter/j/c6cbf5/32.png) [@J\_Cubed](https://boards.straightdope.com/u/J_Cubed)\
**Post date:** [October 17, 2008, 5:32pm UTC](https://boards.straightdope.com/t/i-need-a-script-to-extract-a-file-with-wildcards-from-all-zipfiles-in-a-folder/468405/4 "2008-10-17T17:32:46Z")

</div>

Extract all files from the zips, then pull out the ones you want and delete the rest.

---

<div class="post-metadata">

**Author:** ![Lobsang](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/lobsang/32/4067_2.png) [@Lobsang](https://boards.straightdope.com/u/Lobsang)\
**Post date:** [October 17, 2008, 5:49pm UTC](https://boards.straightdope.com/t/i-need-a-script-to-extract-a-file-with-wildcards-from-all-zipfiles-in-a-folder/468405/5 "2008-10-17T17:49:26Z")

</div>

> [@J\_Cubed](#):
>
> Extract all files from the zips, then pull out the ones you want and delete the rest.

Um… how?  
There are hundreds of zipfiles. I want a shortcut. I don’t want to do this a hundred times and I will QUICKLY fill the HD if I just do an extract all on all files.

---

<div class="post-metadata">

**Author:** ![Lobsang](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/lobsang/32/4067_2.png) [@Lobsang](https://boards.straightdope.com/u/Lobsang)\
**Post date:** [October 17, 2008, 6:08pm UTC](https://boards.straightdope.com/t/i-need-a-script-to-extract-a-file-with-wildcards-from-all-zipfiles-in-a-folder/468405/6 "2008-10-17T18:08:32Z")

</div>

Nevermind. I figured it out with an old copy of pkzip25.exe…

---

<div class="post-metadata">

**Author:** ![Fubaya](https://avatars.discourse-cdn.com/v4/letter/f/c2a13f/32.png) [@Fubaya](https://boards.straightdope.com/u/Fubaya)\
**Post date:** [October 17, 2008, 11:27pm UTC](https://boards.straightdope.com/t/i-need-a-script-to-extract-a-file-with-wildcards-from-all-zipfiles-in-a-folder/468405/7 "2008-10-17T23:27:32Z")

</div>

The way you’re cussing windows, it sounds like you may have Linux. If so, use:

```auto

for file in *.zip ; do unzip "$file" ; mv *.odb /PATH/TO/ANOTHER/FOLDER/; rm *[!.zip?]; done

```

---

<div class="post-metadata">

**Author:** ![chromaticity](https://avatars.discourse-cdn.com/v4/letter/c/cc9497/32.png) [@chromaticity](https://boards.straightdope.com/u/chromaticity)\
**Post date:** [October 19, 2008, 8:28am UTC](https://boards.straightdope.com/t/i-need-a-script-to-extract-a-file-with-wildcards-from-all-zipfiles-in-a-folder/468405/8 "2008-10-19T08:28:56Z")

</div>

How about 7-zip?

```auto

7z.exe e <Archive name - can use *.zip> -o<Output directory - can skip> <Wildcard> -r

```

-r is to recurse subdirectories.
