grouping files into directories by function