All pastes #296209 Raw Edit

Mine

public text v1 · immutable
#296209 ·published 2006-12-30 00:41 UTC
rendered paste body
#!/usr/bin/env python
import glob
import os
import shutil
L = range(1, 100)
def directory():                                                #to verify if directory exists
        for x in glob.glob('*'):
                return x
for i in glob.glob('*.html'):
        if len([x for x in i if x.isdigit()]) == 0:             #if it contains a number
                dir = i[:-5]                                    #remove the '.html'
                if [directory() == dir] == 0:
                        os.mkdir(dir)                           #create the directory which is named i up to .html
                shutil.copy(i, dir)                             #copy the files to the directory
                for y in glob.glob('./*-[1-100].html'):         #remove all files that contain numbers
                        os.remove(y)
                        file = open('howtofixoutput.txt', 'w')  #open file to output the redirect files
                        file.write(i + '\n')
                        file.close()

file2 = open('howtofixoutput.txt', 'r')                         #reopen file to output the redirect filenames
print file2.readlines()                                         #print the redirect filenames