import os, fnmatch
def find_files(directory, pattern):
for root, dirs, files in os.walk(directory):
for basename in files:
if fnmatch.fnmatch(basename, pattern):
filename = os.path.join(root, basename)
yield filename
def find_files_to_list(directory, pattern):
wanted_files = find_files_to_list('/original_project/', '*.html')
for filename in find_files('/copy_project/', '*'):
if filename not in wanted_files:
os.remove(filename)
file_list = []
for root, dirs, files in os.walk(directory):
for basename in files:
if fnmatch.fnmatch(basename, pattern):
filename = os.path.join(root, basename)
file_list.append(filename)
return file_list
wanted_files = find_files_to_list('/original_project/', '*.html')
for filename in find_files('/copy_project/', '*'):
if filename not in wanted_files:
os.remove(filename)