import wx, os, zipfile basedir = os.getcwd() app = wx.App() dialog = wx.DirDialog(None, "Please choose the form directory:",) if dialog.ShowModal() == wx.ID_OK: basedir = dialog.GetPath() else: exit() dialog.Destroy() print 'monkey' def text(): flist = [] print 'Searching %s' % basedir for dirname, subdirs, files in os.walk( basedir ): for fn in [o for o in files if o.lower().endswith('.pdf')]: flist.append( (dirname,fn) ) print ' %s' % fn print '%s file(s) to batch\n' % len(flist) batch = [] i = 0 while flist: batch.append( flist.pop() ) if len(batch) == 10: i += 1 bf = os.path.join( basedir, 'batch-%s.zip' % i ).encode("latin-1") arch = zipfile.ZipFile( bf, 'w', zipfile.ZIP_DEFLATED ) print bf while batch: dn,fn = batch.pop() arch.write( os.path.join(dn,fn), fn.encode("latin-1") ) print ' %s' % fn arch.close() if batch: i += 1 bf = os.path.join( basedir, 'batch-%s.zip' % i ).encode("latin-1") arch = zipfile.ZipFile( bf, 'w', zipfile.ZIP_DEFLATED ) print bf while batch: dn,fn = batch.pop() arch.write( os.path.join(dn,fn), fn.encode("latin-1") ) print ' %s' % fn arch.close()