calculate average for difrectory