I want to write a program that looks into a given folder, groups files that have a certain part of the filename in common and then copy those groups one at a time to another place, using the raw_input prompt to continue or break.
here's what I have: ########### def makegroepen(): global p import os from longestcommonprefix import longestcommonprefix p = raw_input('path') l = os.listdir(p) l.sort() groepen=[] groep=[] basenames=[] for r in l: if r.find('_poly16.mp3'): baselist = r.split('_') mopobasename = baselist[0] if mpbasename not in basenames: basenames.append(mpbasename) for s in l: if longestcommonprefix([s,mpbasename])==mpbasename: print mpbasename if s not in groep: groep.append(s) if len(groep)==6: groepen.append(groep) groep=[] print groepen return groepen def movegr(): global p, groepen for t in groepen: contprompt=raw_input('continue? (n to stop)') if contprompt=='n': break for curr in t: if os.path.isfile(p+'\\'+curr): tempfile = open(p+'\\'+curr, 'rb') tempfile.seek(0) tempfilecont = tempfile.read() dircondition = os.path.exists('c:\\content\\workfolder') if dircondition == False: os.makedirs('c:\\content\\workfolder') destfile = open('c:\\content\\workfolder\\'+curr, 'wb') destfile.write(tempfilecont) destfile.close() if __name__=='__main__': global groepen groepen = makegroepen() movegr() ######## (I renamed 'commonprefix' to 'longestcommonprefix', it is actually just the 'binary search version' I found at http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/252177 ) It works fine when I run this from PythonWin IDE, but after compiling an executable from it (py2exe) it exits whatever I type in the 'continue?' prompt. What am I doing wrong? Thanks, Tim -- http://mail.python.org/mailman/listinfo/python-list