Sethei
Sethei

Reputation: 105

Save this batch variable into a txt file

I'm trying to save this batch variable into a .txt file. This is my current code:

set /p Build=<version.ini
echo %Build%
type %Build%>>"result.txt"
pause

It's supposed to get the text on that .ini file and then save that text into a new .txt file but the result is a long list of random characters. The content of that .ini is a path.

Upvotes: 0

Views: 95

Answers (1)

user7818749
user7818749

Reputation:

You should use echo and not type. You can learn why by opening cmd and running type /? and echo /?

So this will work:

set /p Build=<version.ini
echo %Build%
echo %Build%>>"result.txt"
pause

Additionally, if it is simply your intention to replicate the text to a new file, this would be much shorter:

type version.ini>result.txt

or to find specific text only and send to new file.

type version.ini | findstr /I "Version" >result.txt

or by using copy

copy version.ini result.txt

Upvotes: 1

Related Questions