Handle backslashes properly in path substitution