By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,209 Members | 1,834 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,209 IT Pros & Developers. It's quick & easy.

A 'find' utility that continues through zipped directory structure?

P: n/a
Is there a Python 'find' -like utility that will continue the file
search through any zippped directory structure on the find path?

Sep 27 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"B Mahoney" wrote:
Is there a Python 'find' -like utility that will continue the file
search through any zippped directory structure on the find path?


something like this?

# File: zipfind.py
import fnmatch, os, sys, zipfile

program, root, name = sys.argv

for dirpath, dirnames, filenames in os.walk(root):
for file in fnmatch.filter(filenames, name):
print os.path.join(dirpath, file)
for file in fnmatch.filter(filenames, "*.zip"):
try:
zip = zipfile.ZipFile(os.path.join(dirpath, file))
except zipfile.BadZipfile:
pass # cannot read this file
else:
for f in fnmatch.filter(zip.namelist(), name):
print os.path.join(dirpath, file) + ":" + f

$ python zipfind.py aggdraw "README*"
aggdraw/README
aggdraw/agg2/README.txt
aggdraw/dist/aggdraw-1.1b3-20050925.zip:aggdraw-1.1b3-20050925/README.txt

</F>

Sep 27 '05 #2

P: n/a
An effbot utility? I'll try that.

Thank you

Sep 27 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.