Added function to shrink directory names if needed