Added index to dirname and basename