The error shows up for the line "for file in os.listdir(relevantfile):"
if test == criteria[2]: relevantfolder = dri