Perhaps this is an X-Y problem, and the need to remove the newline is caused by your solution to an unstated requirement? The behaviour is with cmd.exe rather than the cd
command specifically.
In a batch file you can block all command echo and prompt output with @echo off
. So for example:
@echo off
echo Start
cd ..
echo End
Outputs:
Start
End
If you need to report the current working directory, then that is output by cd
with no parameter: e.g:
@echo off
echo Start
cd ..
cd
echo End
executed starting from C:\Users\<username>
outputs:
Start
C:\Users
End