Page 1 of 1

Insert the string '%' (percent) in the echo output

Posted: 21 Nov 2013 06:07
by god_tankian
Hy guys, i'm needing some help.

I'm trying to create an automation here. This automation will create a file that also has DOS commmands. The problem is; when I try to insert some DOS files, the output has no isses, but, when I insert the string %, the DOS ignore as characters and works with it like a DOS command.

Script
echo %Test > Teste.txt

Output
Test

Expected output
%Test

Is it posible to make DOS interpret %Test as string and not as a command?
PS: I already tested the line using ^, but this does not solve the issue, DOS keep ignoring the char even using the ^

Thanks in advance.

Re: Insert the string '%' (percent) in the echo output

Posted: 21 Nov 2013 06:52
by foxidrive
Double the percent.

Code: Select all

>file.txt echo %%test

Re: Insert the string '%' (percent) in the echo output

Posted: 21 Nov 2013 10:05
by god_tankian
Hi foxidrive, solved the issue.

Thanks a lot for your help man, save-me a lot of hours of work.

Have a nice day. XD

Re: Insert the string '%' (percent) in the echo output

Posted: 23 Nov 2013 05:37
by shayanjameel08
Hi Guys let me know that how to Insert a Percent Symbol Beside a PHP String...?

Re: Insert the string '%' (percent) in the echo output

Posted: 23 Nov 2013 06:39
by foxidrive
Do you want to echo tags and stuff?

See here:

Code: Select all

@echo off
set "variable=<blah>20%%</blah>"

for /f "delims=" %%a in ("%variable%") do >file.txt echo(%%a