Fix increment_path()
explicit file vs dir handling
#5523
Merged
increment_path()
explicit file vs dir handling
#5523