sort directories for scanning; store source->target mappings for faster checking