organize the task directory based on index