Refactor to 'get_dir_id' process.