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

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
god_tankian
Posts: 2
Joined: 21 Nov 2013 05:48

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

#1 Post by god_tankian » 21 Nov 2013 06:07

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.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

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

#2 Post by foxidrive » 21 Nov 2013 06:52

Double the percent.

Code: Select all

>file.txt echo %%test

god_tankian
Posts: 2
Joined: 21 Nov 2013 05:48

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

#3 Post by god_tankian » 21 Nov 2013 10:05

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

shayanjameel08
Posts: 10
Joined: 21 Nov 2013 01:07

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

#4 Post by shayanjameel08 » 23 Nov 2013 05:37

Hi Guys let me know that how to Insert a Percent Symbol Beside a PHP String...?

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

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

#5 Post by foxidrive » 23 Nov 2013 06:39

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

Post Reply