Jan-05-2024, 05:16 PM
Try glob?
import glob path1 = '/home/pedro/summer2021/**/' path2 = '/home/pedro/summer2021/EC/*' all_files1 = glob.glob(path1 + '*.odt') all_files2 = glob.glob(path2 + '*.odt') intersect = list(set(all_files1).intersection(set(all_files2)) exceptions = [f for f in all_files1 if not f in intersect] len(exceptions) #26 len(all_files1) #33 len(intersection) #7If memory is a problem you can use iglob()
all_files = glob.iglob(path + '*.odt')iglob returns a generator, not a list.