0

I want to echo this text:cd %~dp0 unchanged to my text file.

but when I run:

echo cd %~dp0>new_file.txt

It stores the result of the cd command in the text file.

Since double quotes dont work, how can i echo this without executing the command cd?

aschipfl
  • 33,626
  • 12
  • 54
  • 99

2 Answers2

2

In batch, you escape % by adding a second % in front of it.

echo cd %%~dp0>new_file.txt
SomethingDark
  • 13,229
  • 5
  • 50
  • 55
-1

If all you are doing is trying to save a current directory (where your batch file is) to a text file just run this.

cd>new_file.txt
Dominique
  • 9
  • 6
  • 2
    The current working directory and the parent directory of the batch file are two totally different things… – aschipfl Jul 23 '21 at 06:04