-1

I need a batch file to make a batch file and i am doing this by using @echo[ text >> E\1.bat instead the output is text
and the batch file is empty

here is my code:

@echo off
(@echo[ if "%!c!%" == "" (set c=) && @echo[ %c% >> C:\encoder-decoder\decodetext.dct) >> E:\storge\1.txt
(@echo[ if "%!c!%" == " " (set c= ) && @echo[ %c% >> C:\encoder-decoder\decodetext.dct) >> E:\storge\1.txt  
(@echo[ if "%!c!%" == "0011." (set c=z) && @echo[ %c% >> C:\encoder-decoder\decodetext.dct) >> E:\storge\1.txt
(@echo[ if "%!c!%" == "0100." (set c=y) && @echo[ %c% >> C:\encoder-decoder\decodetext.dct) >> E:\storge\1.txt 
(@echo[ if "%!c!%" == "0110." (set c=x) && @echo[ %c% >> C:\encoder-decoder\decodetext.dct) >> E:\storge\1.txt  
(@echo[ if "%!c!%" == "100." (set c=w) && @echo[ %c% >> C:\encoder-decoder\decodetext.dct) >> E:\storge\1.txt 
(@echo[ if "%!c!%" == "1110." (set c=v) && @echo[ %c% >> C:\encoder-decoder\decodetext.dct) >> E:\storge\1.txt 
(@echo[ if "%!c!%" == "110." (set c=u) && @echo[ %c% >> C:\encoder-decoder\decodetext.dct) >> E:\storge\1.txt 
(@echo[ if "%!c!%" == "0." (set c=t) && @echo[ %c% >> C:\encoder-decoder\decodetext.dct) >> E:\storge\1.txt
(@echo[ if "%!c!%" == "111." (set c=s) && @echo[ %c% >> C:\encoder-decoder\decodetext.dct) >> E:\storge\1.txt  
(@echo[ if "%!c!%" == "101." (set c=r) && @echo[ %c% >> C:\encoder-decoder\decodetext.dct) >> E:\storge\1.txt 
(@echo[ if "%!c!%" == "0010." (set c=q) && @echo[ %c% >> C:\encoder-decoder\decodetext.dct) >> E:\storge\1.txt  
(@echo[ if "%!c!%" == "1001." (set c=p) && @echo[ %c% >> C:\encoder-decoder\decodetext.dct) >> E:\storge\1.txt 
(@echo[ if "%!c!%" == "000." (set c=o) && @echo[ %c% >> C:\encoder-decoder\decodetext.dct) >> E:\storge\1.txt 
(@echo[ if "%!c!%" == "01." (set c=n) && @echo[ %c% >> C:\encoder-decoder\decodetext.dct) >> E:\storge\1.txt 
(@echo[ if "%!c!%" == "1011." (set c=l) && @echo[ %c% >> C:\encoder-decoder\decodetext.dct) >> E:\storge\1.txt 
(@echo[ if "%!c!%" == "010." (set c=k) && @echo[ %c% >> C:\encoder-decoder\decodetext.dct) >> E:\storge\1.txt 
(@echo[ if "%!c!%" == "1000." (set c=j) && @echo[ %c% >> C:\encoder-decoder\decodetext.dct) >> E:\storge\1.txt 
(@echo[ if "%!c!%" == "11." (set c=i) && @echo[ %c% >> C:\encoder-decoder\decodetext.dct) >> E:\storge\1.txt 
(@echo[ if "%!c!%" == "1111." (set c=h) && @echo[ %c% >> C:\encoder-decoder\decodetext.dct) >> E:\storge\1.txt 
(@echo[ if "%!c!%" == "001." (set c=g) && @echo[ %c% >> C:\encoder-decoder\decodetext.dct) >> E:\storge\1.txt 
(@echo[ if "%!c!%" == "1101." (set c=f) && @echo[ %c% >> C:\encoder-decoder\decodetext.dct) >> E:\storge\1.txt 
(@echo[ if "%!c!%" == "1." (set c=e) && @echo[ %c% >> C:\encoder-decoder\decodetext.dct) >> E:\storge\1.txt 
(@echo[ if "%!c!%" == "011." (set c=d) && @echo[ %c% >> C:\encoder-decoder\decodetext.dct) >> E:\storge\1.txt 
(@echo[ if "%!c!%" == "0101." (set c=c) && @echo[ %c% >> C:\encoder-decoder\decodetext.dct) >> E:\storge\1.txt 
(@echo[ if "%!c!%" == "0111." (set c=b) && @echo[ %c% >> C:\encoder-decoder\decodetext.dct) >> E:\storge\1.txt
(@echo[ if "%!c!%" == "10." (set c=a) && @echo[ %c% >> C:\encoder-decoder\decodetext.dct) >> E:\storge\1.txt
pause

The output i need is:

if "%!c!%" == "" (set c=) && @echo[ %c% >> C:\encoder-decoder\decodetext.dct  

if "%!c!%" == " " (set c= ) && @echo[ %c% >> C:\encoder-decoder\decodetext.dct
if "%!c!%" == "0011." (set c=z) && @echo[ %c% >> C:\encoder-decoder\decodetext.dct
if "%!c!%" == "0100." (set c=y) && @echo[ %c% >> C:\encoder-decoder\decodetext.dct
if "%!c!%" == "0110." (set c=x) && @echo[ %c% >> C:\encoder-decoder\decodetext.dct
if "%!c!%" == "100." (set c=w) && @echo[ %c% >> C:\encoder-decoder\decodetext.dct
if "%!c!%" == "1110." (set c=v) && @echo[ %c% >> C:\encoder-decoder\decodetext.dct
if "%!c!%" == "110." (set c=u) && @echo[ %c% >> C:\encoder-decoder\decodetext.dct
if "%!c!%" == "0." (set c=t) && @echo[ %c% >> C:\encoder-decoder\decodetext.dct
if "%!c!%" == "111." (set c=s) && @echo[ %c% >> C:\encoder-decoder\decodetext.dct
if "%!c!%" == "101." (set c=r) && @echo[ %c% >> C:\encoder-decoder\decodetext.dct
if "%!c!%" == "0010." (set c=q) && @echo[ %c% >> C:\encoder-decoder\decodetext.dct
if "%!c!%" == "1001." (set c=p) && @echo[ %c% >> C:\encoder-decoder\decodetext.dct
if "%!c!%" == "000." (set c=o) && @echo[ %c% >> C:\encoder-decoder\decodetext.dct
if "%!c!%" == "01." (set c=n) && @echo[ %c% >> C:\encoder-decoder\decodetext.dct
if "%!c!%" == "00." (set c=m) && @echo[ %c% >> C:\encoder-decoder\decodetext.dct
if "%!c!%" == "1011." (set c=l) && @echo[ %c% >> C:\encoder-decoder\decodetext.dct
if "%!c!%" == "010." (set c=k) && @echo[ %c% >> C:\encoder-decoder\decodetext.dct
if "%!c!%" == "1000." (set c=j) && @echo[ %c% >> C:\encoder-decoder\decodetext.dct
if "%!c!%" == "11." (set c=i) && @echo[ %c% >> C:\encoder-decoder\decodetext.dct
if "%!c!%" == "1111." (set c=h) && @echo[ %c% >> C:\encoder-decoder\decodetext.dct
if "%!c!%" == "001." (set c=g) && @echo[ %c% >> C:\encoder-decoder\decodetext.dct
if "%!c!%" == "1101." (set c=f) && @echo[ %c% >> C:\encoder-decoder\decodetext.dct
if "%!c!%" == "1." (set c=e) && @echo[ %c% >> C:\encoder-decoder\decodetext.dct
if "%!c!%" == "011." (set c=d) && @echo[ %c% >> C:\encoder-decoder\decodetext.dct
if "%!c!%" == "0101." (set c=c) && @echo[ %c% >> C:\encoder-decoder\decodetext.dct
if "%!c!%" == "0111." (set c=b) && @echo[ %c% >> C:\encoder-decoder\decodetext.dct
if "%!c!%" == "10." (set c=a) && @echo[ %c% >> C:\encoder-decoder\decodetext.dct

Jayjar291
  • 22
  • 7

2 Answers2

0

You should escape special symbols like % or > in the echo:

(echo if "%%!c!%%" == "" ^(set c=^) ^&^& echo %%c%% ^>^> C:\encoder-decoder\decodetext.dct) >> E:\storge\1.txt

will output in E:\storge\1.txt:

if "%!c!%" == "" (set c=) && echo %c% >> C:\encoder-decoder\decodetext.dct
wOxxOm
  • 65,848
  • 11
  • 132
  • 136
0

Excuse me. Your code have a series of different problems; however, I will not talk about they...

The Batch file below perform a process that I guess is equivalent to your code:

@echo off
setlocal EnableDelayedExpansion

rem Define the replacement array
set "letter=abcdefghijklMnopqrstuvwxyz"
set i=0
for %%a in (10 0111 0101 011 1 1101 001 1111 11 1000 010 1011 xxxx
            01 000 1001 0010 101 111 0 110 1110 100 0110 0100 0011) do (
   for %%i in (!i!) do set "replace[%%a.]=!letter:~%%i,1!"
   set /A i+=1
)

rem A couple replacement examples

set c=010.
set newC=!replace[%c%]!
echo Change "%c%" by "%newC%"

set c=1001.
set newC=!replace[%c%]!
echo Change "%c%" by "%newC%"

This method use an array in order to replace a series of if commands with an individual set command each, into a single set command from an array element with variable subscript.

I apologize if this is not what you asked for...

Community
  • 1
  • 1
Aacini
  • 65,180
  • 12
  • 72
  • 108