Help Needed ASAP

December 5, 2011 at 00:43:08
Specs: Windows 7 Home Premium, Intel i5 @ 2.8Ghz
Hey All you smart people outhere, please Help me with my problem.
I have built a batch Binary encoder eg. Hello = 01001000 01100101 01101100 01101100 01101111
(i encoded that with the encoder) But now I want to make a decoder, that can decode that binary back to ASCII from the .txt file.
Here is my source code for the Encoder, Please help me make a decoder!:
@echo off
SetLocal EnableDelayedExpansion
title 8-bit Binary Converter
color a
SET no=0
:begin
echo Welcome to the 8-Bit Binary Translator
echo What do you want to do.
echo.
echo (1) Encode
echo (2) Exit
echo.
set /p ans1=
IF %ans1%==1 goto encode
IF %ans1%==2 goto EOF
cls
echo Your choice is invalid!
Pause
goto begin
:encode
cls
echo Please enter the Letters sepperatly, enter "done" when you are finished. Special Carrecters not supported.
echo So far you have: !char1!!char2!!char3!!char4!!char5!!char6!!char7!!char8!!char9!!char10!!char11!!char12!!char13!!char14!!char15!!char16!!char17!!char18!!char19!!char20!!char21!!char22!!char23!!char24!!char25!!char26!!char27!!char28!!char29!!char30!!char31!!char32!!char33!!char34!!char35!!char36!!char37!!char38!!char39!!char40!!char41!!char42!!char43!!char44!!char45!!char46!!char47!!char48!!char49!!char50!!char51!!char52!!char53!!char54!!char55!!char56!!char57!!char58!!char59!!char60!!char61!!char62!!char63!!char64!!char65!!char66!!char67!!char68!!char69!!char70!!char71!!char72!!char73!!char74!!char75!!char76!!char77!!char78!!char79!!char80!!char81!!char82!!char83!!char84!!char85!!char86!!char87!!char88!!char89!!char90!!char91!!char92!!char93!!char94!!char95!!char96!!char97!!char98!!char99!!char100!!char101!!char102!!char103!!char104!!char105!!char106!!char107!!char108!!char109!!char110!!char111!!char112!!char113!!char114!!char115!!char116!!char117!!char118!!char119!!char120!!char121!!char122!!char123!!char124!!char125!!char126!!char127!!char128!!char129!!char130!!char131!!char132!!char133!!char134!!char135!!char136!!char137!!char138!!char139!!char140!!char141!!char142!!char143!!char144!!char145!!char146!!char147!!char148!!char149!!char150!!char151!!char152!!char153!!char154!!char155!!char156!!char157!!char158!!char159!!char160!!char161!!char162!!char163!!char164!!char165!!char166!!char167!!char168!!char169!!char170!!char171!!char172!!char173!!char174!!char175!!char176!!char177!!char178!!char179!!char180!!char181!!char182!!char183!!char184!!char185!!char186!!char187!!char188!!char189!!char190!!char191!!char192!!char193!!char194!!char195!!char196!!char197!!char198!!char199!!char200!!char201!!char202!!char203!!char204!!char205!!char206!!char207!!char208!!char209!!char210!!char211!!char212!!char213!!char214!!char215!!char216!!char217!!char218!!char219!!char220!!char221!!char222!!char223!!char224!!char225!!char226!!char227!!char228!!char229!!char230!!char231!!char232!!char233!!char234!!char235!!char236!!char237!!char238!!char239!!char240!!char241!!char242!!char243!!char244!!char245!!char246!!char247!!char248!!char249!!char250!!char251!!char252!!char253!!char254!!char255!!char256!!char257!!char258!!char259!!char260!!char261!!char262!!char263!!char264!!char265!!char266!!char267!!char268!!char269!!char270!!char271!!char272!!char273!!char274!!char275!!char276!!char277!!char278!!char279!!char280!!char281!!char282!!char283!!char284!!char285!!char286!!char287!!char288!!char289!!char290!!char291!!char292!!char293!!char294!!char295!!char296!!char297!!char298!!char299!!char300!!char301!!char302!!char303!!char304!!char305!!char306!!char307!!char308!!char309!!char310!!char311!!char312!!char313!!char314!!char315!!char316!!char317!!char318!!char319!!char320!!char321!!char322!!char323!!char324!!char325!!char326!!char327!!char328!!char329!!char330!!char331!!char332!!char333!!char334!!char335!!char336!!char337!!char338!!char339!!char340!!char341!!char342!!char343!!char344!!char345!!char346!!char347!!char348!!char349!!char350!!char351!!char352!!char353!!char354!!char355!!char356!!char357!!char358!!char359!!char360!!char361!!char362!!char363!!char372!!char373!!char374!!char375!!char376!!char377!!char378!!char379!!char380!!char381!!char382!!char383!!char384!!char385!!char386!!char387!!char388!!char389!!char390!!char391!!char392!!char393!!char394!!char395!!char396!!char397!!char398!!char399!!char400!!char401!!char402!!char403!!char404!!char405!!char406!!char407!!char408!!char409!!char410!!char411!!char412!!char413!!char414!!char415!!char416!!char417!!char418!!char419!!char420!!char421!!char422!!char423!!char424!!char425!!char426!!char427!!char428!!char429!!char430!!char431!!char432!!char433!!char434!!char435!!char436!!char437!!char438!!char439!!char440!!char441!!char442!!char443!!char444!!char445!!char446!!char447!!char448!!char449!!char450!!char451!!char452!!char453!!char454!!char455!!char456!!char457!!char458!!char459!!char460!!char461!!char462!!char463!!char464!!char465!!char466!!char467!!char468!!char469!!char470!!char471!!char472!!char473!!char474!!char475!!char476!!char477!!char478!!char479!!char480!!char481!!char482!!char483!!char484!!char485!!char486!!char487!!char488!!char489!!char490!!char491!!char492!!char493!!char494!!char495!!char496!!char497!!char498!!char499!!char500!
set /p "let1=>"
Set /a no=%no%+1
:: Alpha
IF %let1%==A set var%no%= 01000001 & set char%no%=A
IF %let1%==a set var%no%= 01100001 & set char%no%=a
IF %let1%==B set var%no%= 01000010 & set char%no%=B
IF %let1%==b set var%no%= 01100010 & set char%no%=b
IF %let1%==C set var%no%= 01000011 & set char%no%=C
IF %let1%==c set var%no%= 01100011 & set char%no%=c
IF %let1%==D set var%no%= 01000100 & set char%no%=D
IF %let1%==d set var%no%= 01100100 & set char%no%=d
IF %let1%==E set var%no%= 01000101 & set char%no%=E
IF %let1%==e set var%no%= 01100101 & set char%no%=e
IF %let1%==F set var%no%= 01000110 & set char%no%=F
IF %let1%==f set var%no%= 01100110 & set char%no%=f
IF %let1%==G set var%no%= 01000111 & set char%no%=G
IF %let1%==g set var%no%= 01100111 & set char%no%=g
IF %let1%==H set var%no%= 01001000 & set char%no%=H
IF %let1%==h set var%no%= 01101000 & set char%no%=h
IF %let1%==I set var%no%= 01001001 & set char%no%=I
IF %let1%==i set var%no%= 01101001 & set char%no%=i
IF %let1%==J set var%no%= 01001010 & set char%no%=J
IF %let1%==j set var%no%= 01101010 & set char%no%=j
IF %let1%==K set var%no%= 01001011 & set char%no%=K
IF %let1%==k set var%no%= 01101011 & set char%no%=k
IF %let1%==L set var%no%= 01001100 & set char%no%=L
IF %let1%==l set var%no%= 01101100 & set char%no%=l
IF %let1%==M set var%no%= 01001101 & set char%no%=M
IF %let1%==m set var%no%= 01101101 & set char%no%=m
IF %let1%==N set var%no%= 01001110 & set char%no%=N
IF %let1%==n set var%no%= 01101110 & set char%no%=n
IF %let1%==O set var%no%= 01001111 & set char%no%=O
IF %let1%==o set var%no%= 01101111 & set char%no%=o
IF %let1%==P set var%no%= 01010000 & set char%no%=P
IF %let1%==p set var%no%= 01110000 & set char%no%=p
IF %let1%==Q set var%no%= 01010001 & set char%no%=Q
IF %let1%==q set var%no%= 01110001 & set char%no%=q
IF %let1%==R set var%no%= 01010010 & set char%no%=R
IF %let1%==r set var%no%= 01110010 & set char%no%=r
IF %let1%==S set var%no%= 01010011 & set char%no%=S
IF %let1%==s set var%no%= 01110011 & set char%no%=s
IF %let1%==T set var%no%= 01010100 & set char%no%=T
IF %let1%==t set var%no%= 01110100 & set char%no%=t
IF %let1%==U set var%no%= 01010101 & set char%no%=U
IF %let1%==u set var%no%= 01110101 & set char%no%=u
IF %let1%==V set var%no%= 01010110 & set char%no%=V
IF %let1%==v set var%no%= 01110110 & set char%no%=v
IF %let1%==W set var%no%= 01010111 & set char%no%=W
IF %let1%==w set var%no%= 01110111 & set char%no%=w
IF %let1%==X set var%no%= 01011000 & set char%no%=X
IF %let1%==x set var%no%= 01111000 & set char%no%=x
IF %let1%==Y set var%no%= 01011001 & set char%no%=Y
IF %let1%==y set var%no%= 01111001 & set char%no%=y
IF %let1%==Z set var%no%= 01011010 & set char%no%=Z
IF %let1%==z set var%no%= 01111010 & set char%no%=z
:: Numeric
IF %let1%==1 set var%no%= 00110001 & set char%no%=1
IF %let1%==2 set var%no%= 00110010 & set char%no%=2
IF %let1%==3 set var%no%= 00110011 & set char%no%=3
IF %let1%==4 set var%no%= 00110100 & set char%no%=4
IF %let1%==5 set var%no%= 00110101 & set char%no%=5
IF %let1%==6 set var%no%= 00110110 & set char%no%=6
IF %let1%==7 set var%no%= 00110111 & set char%no%=7
IF %let1%==8 set var%no%= 00111000 & set char%no%=8
IF %let1%==9 set var%no%= 00111001 & set char%no%=9
IF %let1%==0 set var%no%= 00110000 & set char%no%=0
:: Check if done
IF %let1%==done goto exit2
IF %let1%==DONE goto exit2
goto encode

:exit2
Echo Enter your filename
set /p "filename=>"
echo !var1!!var2!!var3!!var4!!var5!!var6!!var7!!var8!!var9!!var10!!var11!!var12!!var13!!var14!!var15!!var16!!var17!!var18!!var19!!var20!!var21!!var22!!var23!!var24!!var25!!var26!!var27!!var28!!var29!!var30!!var31!!var32!!var33!!var34!!var35!!var36!!var37!!var38!!var39!!var40!!var41!!var42!!var43!!var44!!var45!!var46!!var47!!var48!!var49!!var50!!var51!!var52!!var53!!var54!!var55!!var56!!var57!!var58!!var59!!var60!!var61!!var62!!var63!!var64!!var65!!var66!!var67!!var68!!var69!!var70!!var71!!var72!!var73!!var74!!var75!!var76!!var77!!var78!!var79!!var80!!var81!!var82!!var83!!var84!!var85!!var86!!var87!!var88!!var89!!var90!!var91!!var92!!var93!!var94!!var95!!var96!!var97!!var98!!var99!!var100!!var101!!var102!!var103!!var104!!var105!!var106!!var107!!var108!!var109!!var110!!var111!!var112!!var113!!var114!!var115!!var116!!var117!!var118!!var119!!var120!!var121!!var122!!var123!!var124!!var125!!var126!!var127!!var128!!var129!!var130!!var131!!var132!!var133!!var134!!var135!!var136!!var137!!var138!!var139!!var140!!var141!!var142!!var143!!var144!!var145!!var146!!var147!!var148!!var149!!var150!!var151!!var152!!var153!!var154!!var155!!var156!!var157!!var158!!var159!!var160!!var161!!var162!!var163!!var164!!var165!!var166!!var167!!var168!!var169!!var170!!var171!!var172!!var173!!var174!!var175!!var176!!var177!!var178!!var179!!var180!!var181!!var182!!var183!!var184!!var185!!var186!!var187!!var188!!var189!!var190!!var191!!var192!!var193!!var194!!var195!!var196!!var197!!var198!!var199!!var200!!var201!!var202!!var203!!var204!!var205!!var206!!var207!!var208!!var209!!var210!!var211!!var212!!var213!!var214!!var215!!var216!!var217!!var218!!var219!!var220!!var221!!var222!!var223!!var224!!var225!!var226!!var227!!var228!!var229!!var230!!var231!!var232!!var233!!var234!!var235!!var236!!var237!!var238!!var239!!var240!!var241!!var242!!var243!!var244!!var245!!var246!!var247!!var248!!var249!!var250!!var251!!var252!!var253!!var254!!var255!!var256!!var257!!var258!!var259!!var260!!var261!!var262!!var263!!var264!!var265!!var266!!var267!!var268!!var269!!var270!!var271!!var272!!var273!!var274!!var275!!var276!!var277!!var278!!var279!!var280!!var281!!var282!!var283!!var284!!var285!!var286!!var287!!var288!!var289!!var290!!var291!!var292!!var293!!var294!!var295!!var296!!var297!!var298!!var299!!var300!!var301!!var302!!var303!!var304!!var305!!var306!!var307!!var308!!var309!!var310!!var311!!var312!!var313!!var314!!var315!!var316!!var317!!var318!!var319!!var320!!var321!!var322!!var323!!var324!!var325!!var326!!var327!!var328!!var329!!var330!!var331!!var332!!var333!!var334!!var335!!var336!!var337!!var338!!var339!!var340!!var341!!var342!!var343!!var344!!var345!!var346!!var347!!var348!!var349!!var350!!var351!!var352!!var353!!var354!!var355!!var356!!var357!!var358!!var359!!var360!!var361!!var362!!var363!!var372!!var373!!var374!!var375!!var376!!var377!!var378!!var379!!var380!!var381!!var382!!var383!!var384!!var385!!var386!!var387!!var388!!var389!!var390!!var391!!var392!!var393!!var394!!var395!!var396!!var397!!var398!!var399!!var400!!var401!!var402!!var403!!var404!!var405!!var406!!var407!!var408!!var409!!var410!!var411!!var412!!var413!!var414!!var415!!var416!!var417!!var418!!var419!!var420!!var421!!var422!!var423!!var424!!var425!!var426!!var427!!var428!!var429!!var430!!var431!!var432!!var433!!var434!!var435!!var436!!var437!!var438!!var439!!var440!!var441!!var442!!var443!!var444!!var445!!var446!!var447!!var448!!var449!!var450!!var451!!var452!!var453!!var454!!var455!!var456!!var457!!var458!!var459!!var460!!var461!!var462!!var463!!var464!!var465!!var466!!var467!!var468!!var469!!var470!!var471!!var472!!var473!!var474!!var475!!var476!!var477!!var478!!var479!!var480!!var481!!var482!!var483!!var484!!var485!!var486!!var487!!var488!!var489!!var490!!var491!!var492!!var493!!var494!!var495!!var496!!var497!!var498!!var499!!var500! >> %filename%.txt
Echo Completed...
pause
set /p variable=<%filename%.txt
echo Your Text translates to:
echo %variable%
echo Press any key to exit...
pause>nul
cls
exit


See More: Help Needed ASAP

Report •

#1
December 5, 2011 at 03:07:38
Take this:
IF %let1%==D set var%no%= 01000100 & set char%no%=D

and reverse the logic:
IF %var%no%= 01000100 set let1%==D & set char%no%=D

>> %filename%.txt
becomes
<< %filename%.txt


Report •

#2
December 5, 2011 at 03:11:49
Thanks, ill see what i can do and Post my final script here.

Report •

#3
December 5, 2011 at 03:34:54
OK i am done, but I have a problem. IT DOES'nt translate: Test it yourself.
script:
@echo off
SetLocal EnableDelayedExpansion
title 8-bit Binary Encoder
color a
SET no=0
:begin
echo Welcome to the 8-Bit Binary Translator
echo What do you want to do.
echo.
echo (1) Encode
echo (2) Decode
echo (3) Exit
echo.
set /p ans1=
IF %ans1%==1 goto encode
IF %ans1%==2 goto decode
IF %ans1%==3 goto EOF
cls
echo Your choice is invalid!
Pause
goto begin
:encode
cls
echo Please enter the Letters sepperatly, enter "done" when you are finished.
echo Special characters not supported.
echo So far you have: !char1!!char2!!char3!!char4!!char5!!char6!!char7!!char8!!char9!!char10!!char11!!char12!!char13!!char14!!char15!!char16!!char17!!char18!!char19!!char20!!char21!!char22!!char23!!char24!!char25!!char26!!char27!!char28!!char29!!char30!!char31!!char32!!char33!!char34!!char35!!char36!!char37!!char38!!char39!!char40!!char41!!char42!!char43!!char44!!char45!!char46!!char47!!char48!!char49!!char50!!char51!!char52!!char53!!char54!!char55!!char56!!char57!!char58!!char59!!char60!!char61!!char62!!char63!!char64!!char65!!char66!!char67!!char68!!char69!!char70!!char71!!char72!!char73!!char74!!char75!!char76!!char77!!char78!!char79!!char80!!char81!!char82!!char83!!char84!!char85!!char86!!char87!!char88!!char89!!char90!!char91!!char92!!char93!!char94!!char95!!char96!!char97!!char98!!char99!!char100!!char101!!char102!!char103!!char104!!char105!!char106!!char107!!char108!!char109!!char110!!char111!!char112!!char113!!char114!!char115!!char116!!char117!!char118!!char119!!char120!!char121!!char122!!char123!!char124!!char125!!char126!!char127!!char128!!char129!!char130!!char131!!char132!!char133!!char134!!char135!!char136!!char137!!char138!!char139!!char140!!char141!!char142!!char143!!char144!!char145!!char146!!char147!!char148!!char149!!char150!!char151!!char152!!char153!!char154!!char155!!char156!!char157!!char158!!char159!!char160!!char161!!char162!!char163!!char164!!char165!!char166!!char167!!char168!!char169!!char170!!char171!!char172!!char173!!char174!!char175!!char176!!char177!!char178!!char179!!char180!!char181!!char182!!char183!!char184!!char185!!char186!!char187!!char188!!char189!!char190!!char191!!char192!!char193!!char194!!char195!!char196!!char197!!char198!!char199!!char200!!char201!!char202!!char203!!char204!!char205!!char206!!char207!!char208!!char209!!char210!!char211!!char212!!char213!!char214!!char215!!char216!!char217!!char218!!char219!!char220!!char221!!char222!!char223!!char224!!char225!!char226!!char227!!char228!!char229!!char230!!char231!!char232!!char233!!char234!!char235!!char236!!char237!!char238!!char239!!char240!!char241!!char242!!char243!!char244!!char245!!char246!!char247!!char248!!char249!!char250!!char251!!char252!!char253!!char254!!char255!!char256!!char257!!char258!!char259!!char260!!char261!!char262!!char263!!char264!!char265!!char266!!char267!!char268!!char269!!char270!!char271!!char272!!char273!!char274!!char275!!char276!!char277!!char278!!char279!!char280!!char281!!char282!!char283!!char284!!char285!!char286!!char287!!char288!!char289!!char290!!char291!!char292!!char293!!char294!!char295!!char296!!char297!!char298!!char299!!char300!!char301!!char302!!char303!!char304!!char305!!char306!!char307!!char308!!char309!!char310!!char311!!char312!!char313!!char314!!char315!!char316!!char317!!char318!!char319!!char320!!char321!!char322!!char323!!char324!!char325!!char326!!char327!!char328!!char329!!char330!!char331!!char332!!char333!!char334!!char335!!char336!!char337!!char338!!char339!!char340!!char341!!char342!!char343!!char344!!char345!!char346!!char347!!char348!!char349!!char350!!char351!!char352!!char353!!char354!!char355!!char356!!char357!!char358!!char359!!char360!!char361!!char362!!char363!!char372!!char373!!char374!!char375!!char376!!char377!!char378!!char379!!char380!!char381!!char382!!char383!!char384!!char385!!char386!!char387!!char388!!char389!!char390!!char391!!char392!!char393!!char394!!char395!!char396!!char397!!char398!!char399!!char400!!char401!!char402!!char403!!char404!!char405!!char406!!char407!!char408!!char409!!char410!!char411!!char412!!char413!!char414!!char415!!char416!!char417!!char418!!char419!!char420!!char421!!char422!!char423!!char424!!char425!!char426!!char427!!char428!!char429!!char430!!char431!!char432!!char433!!char434!!char435!!char436!!char437!!char438!!char439!!char440!!char441!!char442!!char443!!char444!!char445!!char446!!char447!!char448!!char449!!char450!!char451!!char452!!char453!!char454!!char455!!char456!!char457!!char458!!char459!!char460!!char461!!char462!!char463!!char464!!char465!!char466!!char467!!char468!!char469!!char470!!char471!!char472!!char473!!char474!!char475!!char476!!char477!!char478!!char479!!char480!!char481!!char482!!char483!!char484!!char485!!char486!!char487!!char488!!char489!!char490!!char491!!char492!!char493!!char494!!char495!!char496!!char497!!char498!!char499!!char500!
set /p "let1=>"
Set /a no=%no%+1
:: Alpha
IF %let1%==A set var%no%= 01000001 & set char%no%=A
IF %let1%==a set var%no%= 01100001 & set char%no%=a
IF %let1%==B set var%no%= 01000010 & set char%no%=B
IF %let1%==b set var%no%= 01100010 & set char%no%=b
IF %let1%==C set var%no%= 01000011 & set char%no%=C
IF %let1%==c set var%no%= 01100011 & set char%no%=c
IF %let1%==D set var%no%= 01000100 & set char%no%=D
IF %let1%==d set var%no%= 01100100 & set char%no%=d
IF %let1%==E set var%no%= 01000101 & set char%no%=E
IF %let1%==e set var%no%= 01100101 & set char%no%=e
IF %let1%==F set var%no%= 01000110 & set char%no%=F
IF %let1%==f set var%no%= 01100110 & set char%no%=f
IF %let1%==G set var%no%= 01000111 & set char%no%=G
IF %let1%==g set var%no%= 01100111 & set char%no%=g
IF %let1%==H set var%no%= 01001000 & set char%no%=H
IF %let1%==h set var%no%= 01101000 & set char%no%=h
IF %let1%==I set var%no%= 01001001 & set char%no%=I
IF %let1%==i set var%no%= 01101001 & set char%no%=i
IF %let1%==J set var%no%= 01001010 & set char%no%=J
IF %let1%==j set var%no%= 01101010 & set char%no%=j
IF %let1%==K set var%no%= 01001011 & set char%no%=K
IF %let1%==k set var%no%= 01101011 & set char%no%=k
IF %let1%==L set var%no%= 01001100 & set char%no%=L
IF %let1%==l set var%no%= 01101100 & set char%no%=l
IF %let1%==M set var%no%= 01001101 & set char%no%=M
IF %let1%==m set var%no%= 01101101 & set char%no%=m
IF %let1%==N set var%no%= 01001110 & set char%no%=N
IF %let1%==n set var%no%= 01101110 & set char%no%=n
IF %let1%==O set var%no%= 01001111 & set char%no%=O
IF %let1%==o set var%no%= 01101111 & set char%no%=o
IF %let1%==P set var%no%= 01010000 & set char%no%=P
IF %let1%==p set var%no%= 01110000 & set char%no%=p
IF %let1%==Q set var%no%= 01010001 & set char%no%=Q
IF %let1%==q set var%no%= 01110001 & set char%no%=q
IF %let1%==R set var%no%= 01010010 & set char%no%=R
IF %let1%==r set var%no%= 01110010 & set char%no%=r
IF %let1%==S set var%no%= 01010011 & set char%no%=S
IF %let1%==s set var%no%= 01110011 & set char%no%=s
IF %let1%==T set var%no%= 01010100 & set char%no%=T
IF %let1%==t set var%no%= 01110100 & set char%no%=t
IF %let1%==U set var%no%= 01010101 & set char%no%=U
IF %let1%==u set var%no%= 01110101 & set char%no%=u
IF %let1%==V set var%no%= 01010110 & set char%no%=V
IF %let1%==v set var%no%= 01110110 & set char%no%=v
IF %let1%==W set var%no%= 01010111 & set char%no%=W
IF %let1%==w set var%no%= 01110111 & set char%no%=w
IF %let1%==X set var%no%= 01011000 & set char%no%=X
IF %let1%==x set var%no%= 01111000 & set char%no%=x
IF %let1%==Y set var%no%= 01011001 & set char%no%=Y
IF %let1%==y set var%no%= 01111001 & set char%no%=y
IF %let1%==Z set var%no%= 01011010 & set char%no%=Z
IF %let1%==z set var%no%= 01111010 & set char%no%=z
:: Numeric
IF %let1%==1 set var%no%= 00110001 & set char%no%=1
IF %let1%==2 set var%no%= 00110010 & set char%no%=2
IF %let1%==3 set var%no%= 00110011 & set char%no%=3
IF %let1%==4 set var%no%= 00110100 & set char%no%=4
IF %let1%==5 set var%no%= 00110101 & set char%no%=5
IF %let1%==6 set var%no%= 00110110 & set char%no%=6
IF %let1%==7 set var%no%= 00110111 & set char%no%=7
IF %let1%==8 set var%no%= 00111000 & set char%no%=8
IF %let1%==9 set var%no%= 00111001 & set char%no%=9
IF %let1%==0 set var%no%= 00110000 & set char%no%=0
:: Check if done
IF %let1%==done goto exit2
IF %let1%==DONE goto exit2
goto encode

:exit2
Echo Enter your filename
set /p "filename=>"
echo !var1!!var2!!var3!!var4!!var5!!var6!!var7!!var8!!var9!!var10!!var11!!var12!!var13!!var14!!var15!!var16!!var17!!var18!!var19!!var20!!var21!!var22!!var23!!var24!!var25!!var26!!var27!!var28!!var29!!var30!!var31!!var32!!var33!!var34!!var35!!var36!!var37!!var38!!var39!!var40!!var41!!var42!!var43!!var44!!var45!!var46!!var47!!var48!!var49!!var50!!var51!!var52!!var53!!var54!!var55!!var56!!var57!!var58!!var59!!var60!!var61!!var62!!var63!!var64!!var65!!var66!!var67!!var68!!var69!!var70!!var71!!var72!!var73!!var74!!var75!!var76!!var77!!var78!!var79!!var80!!var81!!var82!!var83!!var84!!var85!!var86!!var87!!var88!!var89!!var90!!var91!!var92!!var93!!var94!!var95!!var96!!var97!!var98!!var99!!var100!!var101!!var102!!var103!!var104!!var105!!var106!!var107!!var108!!var109!!var110!!var111!!var112!!var113!!var114!!var115!!var116!!var117!!var118!!var119!!var120!!var121!!var122!!var123!!var124!!var125!!var126!!var127!!var128!!var129!!var130!!var131!!var132!!var133!!var134!!var135!!var136!!var137!!var138!!var139!!var140!!var141!!var142!!var143!!var144!!var145!!var146!!var147!!var148!!var149!!var150!!var151!!var152!!var153!!var154!!var155!!var156!!var157!!var158!!var159!!var160!!var161!!var162!!var163!!var164!!var165!!var166!!var167!!var168!!var169!!var170!!var171!!var172!!var173!!var174!!var175!!var176!!var177!!var178!!var179!!var180!!var181!!var182!!var183!!var184!!var185!!var186!!var187!!var188!!var189!!var190!!var191!!var192!!var193!!var194!!var195!!var196!!var197!!var198!!var199!!var200!!var201!!var202!!var203!!var204!!var205!!var206!!var207!!var208!!var209!!var210!!var211!!var212!!var213!!var214!!var215!!var216!!var217!!var218!!var219!!var220!!var221!!var222!!var223!!var224!!var225!!var226!!var227!!var228!!var229!!var230!!var231!!var232!!var233!!var234!!var235!!var236!!var237!!var238!!var239!!var240!!var241!!var242!!var243!!var244!!var245!!var246!!var247!!var248!!var249!!var250!!var251!!var252!!var253!!var254!!var255!!var256!!var257!!var258!!var259!!var260!!var261!!var262!!var263!!var264!!var265!!var266!!var267!!var268!!var269!!var270!!var271!!var272!!var273!!var274!!var275!!var276!!var277!!var278!!var279!!var280!!var281!!var282!!var283!!var284!!var285!!var286!!var287!!var288!!var289!!var290!!var291!!var292!!var293!!var294!!var295!!var296!!var297!!var298!!var299!!var300!!var301!!var302!!var303!!var304!!var305!!var306!!var307!!var308!!var309!!var310!!var311!!var312!!var313!!var314!!var315!!var316!!var317!!var318!!var319!!var320!!var321!!var322!!var323!!var324!!var325!!var326!!var327!!var328!!var329!!var330!!var331!!var332!!var333!!var334!!var335!!var336!!var337!!var338!!var339!!var340!!var341!!var342!!var343!!var344!!var345!!var346!!var347!!var348!!var349!!var350!!var351!!var352!!var353!!var354!!var355!!var356!!var357!!var358!!var359!!var360!!var361!!var362!!var363!!var372!!var373!!var374!!var375!!var376!!var377!!var378!!var379!!var380!!var381!!var382!!var383!!var384!!var385!!var386!!var387!!var388!!var389!!var390!!var391!!var392!!var393!!var394!!var395!!var396!!var397!!var398!!var399!!var400!!var401!!var402!!var403!!var404!!var405!!var406!!var407!!var408!!var409!!var410!!var411!!var412!!var413!!var414!!var415!!var416!!var417!!var418!!var419!!var420!!var421!!var422!!var423!!var424!!var425!!var426!!var427!!var428!!var429!!var430!!var431!!var432!!var433!!var434!!var435!!var436!!var437!!var438!!var439!!var440!!var441!!var442!!var443!!var444!!var445!!var446!!var447!!var448!!var449!!var450!!var451!!var452!!var453!!var454!!var455!!var456!!var457!!var458!!var459!!var460!!var461!!var462!!var463!!var464!!var465!!var466!!var467!!var468!!var469!!var470!!var471!!var472!!var473!!var474!!var475!!var476!!var477!!var478!!var479!!var480!!var481!!var482!!var483!!var484!!var485!!var486!!var487!!var488!!var489!!var490!!var491!!var492!!var493!!var494!!var495!!var496!!var497!!var498!!var499!!var500! >> %filename%.txt
Echo Completed...
pause
set /p variable=<%filename%.txt
echo Your Text translates to:
echo %variable%
echo Press any key to exit...
pause>nul
cls
exit

:decode
cls
echo.The code must be on one line of the .txt document
echo.
echo File name(No extension)
set /p FileName=">
if not exist "%FileName%.txt" (
echo.No such file exists, %Filename%.txt
pause
goto decode
)
set /p FC= <%FileName%.txt
set AODL=0
set END=
:DecodeLoop
if "%END%" == "True" goto BreakDecodeLoop
cls
echo.Decoding, %AODL% Letters Sorted
echo.
set TD=!FC:~%AODL%,6!
if "%TD%" == "01011010" set DL%AODL%=Z
if "%TD%" == "01011001" set DL%AODL%=Y
if "%TD%" == "01011000" set DL%AODL%=X
if "%TD%" == "01010111" set DL%AODL%=W
if "%TD%" == "01010110" set DL%AODL%=V
if "%TD%" == "01010101" set DL%AODL%=U
if "%TD%" == "01010100" set DL%AODL%=T
if "%TD%" == "01010011" set DL%AODL%=S
if "%TD%" == "01010010" set DL%AODL%=R
if "%TD%" == "01010001" set DL%AODL%=Q
if "%TD%" == "01010000" set DL%AODL%=P
if "%TD%" == "01001111" set DL%AODL%=O
if "%TD%" == "01001110" set DL%AODL%=N
if "%TD%" == "01001101" set DL%AODL%=M
if "%TD%" == "01001100" set DL%AODL%=L
if "%TD%" == "01001011" set DL%AODL%=K
if "%TD%" == "01001010" set DL%AODL%=J
if "%TD%" == "01001001" set DL%AODL%=I
if "%TD%" == "01001000" set DL%AODL%=H
if "%TD%" == "01000111" set DL%AODL%=G
if "%TD%" == "01000110" set DL%AODL%=F
if "%TD%" == "01000101" set DL%AODL%=E
if "%TD%" == "01000100" set DL%AODL%=D
if "%TD%" == "01000011" set DL%AODL%=C
if "%TD%" == "01000010" set DL%AODL%=B
if "%TD%" == "01000001" set DL%AODL%=A
if "%TD%" == "00110001" set DL%AODL%=1
if "%TD%" == "00110010" set DL%AODL%=2
if "%TD%" == "00110011" set DL%AODL%=3
if "%TD%" == "00110100" set DL%AODL%=4
if "%TD%" == "00110101" set DL%AODL%=5
if "%TD%" == "00110110" set DL%AODL%=6
if "%TD%" == "00110111" set DL%AODL%=7
if "%TD%" == "00111000" set DL%AODL%=8
if "%TD%" == "00111001" set DL%AODL%=9
if "%TD%" == "00110000" set DL%AODL%=0
if "%TD%" == "100101" set DL%AODL%=-
if "%TD%" == "" if "%LastLetter%" == "" set END=True
Echo.!TD! - !DL%AODL%!
set LastLetter=%TD%
set /a AODL=%AODL% + 1
goto DecodeLoop
:BreakDecodeLoop
set DTID=-2
set DeTranslatedWord=%DL1%
:DeTranslatingLoop
cls
set /a DTID=%DTID% + 1
echo.Finishing...
set DeTranslatedWord=%DeTranslatedWord%!DL%DTID%!
if %DTID% GTR %AODL% goto BreakDeTranslatingLoop
goto DeTranslatingLoop
:BreakDeTranslatingLoop
cls
if Exist Translation-Decoded.txt del Translation-Decoded.txt
echo.%DeTranslatedWord% >Translation-Decoded.txt
start Translation-Decoded.txt
cls
echo.Translated!
echo.
echo.
pause >nul
goto begin


Report •

Related Solutions

#4
December 8, 2011 at 14:23:26
Random musing: Why are people so interested in "converting" text into binary? Hex is 4 times as compact, and obfuscates just as much.

How To Ask Questions The Smart Way


Report •

#5
December 8, 2011 at 22:50:46
That is simple binary is much more interesting. Hexadecimal is broing and does not look so cool wen translated. Here is the source to the binary translator is is now complete.
Source:
@echo off
SetLocal EnableDelayedExpansion
title 8-bit Binary Encoder
set charamount=500
color 0b
SET no=0
:begin
echo.
echo ^|------------------------------------------^|
echo ^|Welcome to the Binary Encoder ^|
echo ^|What do you want to do. ^|
echo ^|------------------------------------------^|
echo ^| (1) Encode Text ^|
echo ^| (2) Decode Binary ^|
echo ^| (3) Exit ^|
echo ^|------------------------------------------^|
set /p "ans1=What do you want to do? >"
IF %ans1%==1 goto encode
IF %ans1%==2 goto decode
IF %ans1%==3 exit
cls
echo Your choice is invalid!
goto begin
:encode
cls
echo Please enter the Letters sepperatly, enter "~" when you are done.
echo Special characters not supported. Use "-" for space. %charamount% Characters Left.
echo So far you have: !char1!!char2!!char3!!char4!!char5!!char6!!char7!!char8!!char9!!char10!!char11!!char12!!char13!!char14!!char15!!char16!!char17!!char18!!char19!!char20!!char21!!char22!!char23!!char24!!char25!!char26!!char27!!char28!!char29!!char30!!char31!!char32!!char33!!char34!!char35!!char36!!char37!!char38!!char39!!char40!!char41!!char42!!char43!!char44!!char45!!char46!!char47!!char48!!char49!!char50!!char51!!char52!!char53!!char54!!char55!!char56!!char57!!char58!!char59!!char60!!char61!!char62!!char63!!char64!!char65!!char66!!char67!!char68!!char69!!char70!!char71!!char72!!char73!!char74!!char75!!char76!!char77!!char78!!char79!!char80!!char81!!char82!!char83!!char84!!char85!!char86!!char87!!char88!!char89!!char90!!char91!!char92!!char93!!char94!!char95!!char96!!char97!!char98!!char99!!char100!!char101!!char102!!char103!!char104!!char105!!char106!!char107!!char108!!char109!!char110!!char111!!char112!!char113!!char114!!char115!!char116!!char117!!char118!!char119!!char120!!char121!!char122!!char123!!char124!!char125!!char126!!char127!!char128!!char129!!char130!!char131!!char132!!char133!!char134!!char135!!char136!!char137!!char138!!char139!!char140!!char141!!char142!!char143!!char144!!char145!!char146!!char147!!char148!!char149!!char150!!char151!!char152!!char153!!char154!!char155!!char156!!char157!!char158!!char159!!char160!!char161!!char162!!char163!!char164!!char165!!char166!!char167!!char168!!char169!!char170!!char171!!char172!!char173!!char174!!char175!!char176!!char177!!char178!!char179!!char180!!char181!!char182!!char183!!char184!!char185!!char186!!char187!!char188!!char189!!char190!!char191!!char192!!char193!!char194!!char195!!char196!!char197!!char198!!char199!!char200!!char201!!char202!!char203!!char204!!char205!!char206!!char207!!char208!!char209!!char210!!char211!!char212!!char213!!char214!!char215!!char216!!char217!!char218!!char219!!char220!!char221!!char222!!char223!!char224!!char225!!char226!!char227!!char228!!char229!!char230!!char231!!char232!!char233!!char234!!char235!!char236!!char237!!char238!!char239!!char240!!char241!!char242!!char243!!char244!!char245!!char246!!char247!!char248!!char249!!char250!!char251!!char252!!char253!!char254!!char255!!char256!!char257!!char258!!char259!!char260!!char261!!char262!!char263!!char264!!char265!!char266!!char267!!char268!!char269!!char270!!char271!!char272!!char273!!char274!!char275!!char276!!char277!!char278!!char279!!char280!!char281!!char282!!char283!!char284!!char285!!char286!!char287!!char288!!char289!!char290!!char291!!char292!!char293!!char294!!char295!!char296!!char297!!char298!!char299!!char300!!char301!!char302!!char303!!char304!!char305!!char306!!char307!!char308!!char309!!char310!!char311!!char312!!char313!!char314!!char315!!char316!!char317!!char318!!char319!!char320!!char321!!char322!!char323!!char324!!char325!!char326!!char327!!char328!!char329!!char330!!char331!!char332!!char333!!char334!!char335!!char336!!char337!!char338!!char339!!char340!!char341!!char342!!char343!!char344!!char345!!char346!!char347!!char348!!char349!!char350!!char351!!char352!!char353!!char354!!char355!!char356!!char357!!char358!!char359!!char360!!char361!!char362!!char363!!char372!!char373!!char374!!char375!!char376!!char377!!char378!!char379!!char380!!char381!!char382!!char383!!char384!!char385!!char386!!char387!!char388!!char389!!char390!!char391!!char392!!char393!!char394!!char395!!char396!!char397!!char398!!char399!!char400!!char401!!char402!!char403!!char404!!char405!!char406!!char407!!char408!!char409!!char410!!char411!!char412!!char413!!char414!!char415!!char416!!char417!!char418!!char419!!char420!!char421!!char422!!char423!!char424!!char425!!char426!!char427!!char428!!char429!!char430!!char431!!char432!!char433!!char434!!char435!!char436!!char437!!char438!!char439!!char440!!char441!!char442!!char443!!char444!!char445!!char446!!char447!!char448!!char449!!char450!!char451!!char452!!char453!!char454!!char455!!char456!!char457!!char458!!char459!!char460!!char461!!char462!!char463!!char464!!char465!!char466!!char467!!char468!!char469!!char470!!char471!!char472!!char473!!char474!!char475!!char476!!char477!!char478!!char479!!char480!!char481!!char482!!char483!!char484!!char485!!char486!!char487!!char488!!char489!!char490!!char491!!char492!!char493!!char494!!char495!!char496!!char497!!char498!!char499!!char500!
set /p "let1=>"
Set /a no=%no%+1
set /a charamount=%charamount%-1
:: Alpha
IF %let1%==A set var%no%= 01000001 & set char%no%=A
IF %let1%==a set var%no%= 01100001 & set char%no%=a
IF %let1%==B set var%no%= 01000010 & set char%no%=B
IF %let1%==b set var%no%= 01100010 & set char%no%=b
IF %let1%==C set var%no%= 01000011 & set char%no%=C
IF %let1%==c set var%no%= 01100011 & set char%no%=c
IF %let1%==D set var%no%= 01000100 & set char%no%=D
IF %let1%==d set var%no%= 01100100 & set char%no%=d
IF %let1%==E set var%no%= 01000101 & set char%no%=E
IF %let1%==e set var%no%= 01100101 & set char%no%=e
IF %let1%==F set var%no%= 01000110 & set char%no%=F
IF %let1%==f set var%no%= 01100110 & set char%no%=f
IF %let1%==G set var%no%= 01000111 & set char%no%=G
IF %let1%==g set var%no%= 01100111 & set char%no%=g
IF %let1%==H set var%no%= 01001000 & set char%no%=H
IF %let1%==h set var%no%= 01101000 & set char%no%=h
IF %let1%==I set var%no%= 01001001 & set char%no%=I
IF %let1%==i set var%no%= 01101001 & set char%no%=i
IF %let1%==J set var%no%= 01001010 & set char%no%=J
IF %let1%==j set var%no%= 01101010 & set char%no%=j
IF %let1%==K set var%no%= 01001011 & set char%no%=K
IF %let1%==k set var%no%= 01101011 & set char%no%=k
IF %let1%==L set var%no%= 01001100 & set char%no%=L
IF %let1%==l set var%no%= 01101100 & set char%no%=l
IF %let1%==M set var%no%= 01001101 & set char%no%=M
IF %let1%==m set var%no%= 01101101 & set char%no%=m
IF %let1%==N set var%no%= 01001110 & set char%no%=N
IF %let1%==n set var%no%= 01101110 & set char%no%=n
IF %let1%==O set var%no%= 01001111 & set char%no%=O
IF %let1%==o set var%no%= 01101111 & set char%no%=o
IF %let1%==P set var%no%= 01010000 & set char%no%=P
IF %let1%==p set var%no%= 01110000 & set char%no%=p
IF %let1%==Q set var%no%= 01010001 & set char%no%=Q
IF %let1%==q set var%no%= 01110001 & set char%no%=q
IF %let1%==R set var%no%= 01010010 & set char%no%=R
IF %let1%==r set var%no%= 01110010 & set char%no%=r
IF %let1%==S set var%no%= 01010011 & set char%no%=S
IF %let1%==s set var%no%= 01110011 & set char%no%=s
IF %let1%==T set var%no%= 01010100 & set char%no%=T
IF %let1%==t set var%no%= 01110100 & set char%no%=t
IF %let1%==U set var%no%= 01010101 & set char%no%=U
IF %let1%==u set var%no%= 01110101 & set char%no%=u
IF %let1%==V set var%no%= 01010110 & set char%no%=V
IF %let1%==v set var%no%= 01110110 & set char%no%=v
IF %let1%==W set var%no%= 01010111 & set char%no%=W
IF %let1%==w set var%no%= 01110111 & set char%no%=w
IF %let1%==X set var%no%= 01011000 & set char%no%=X
IF %let1%==x set var%no%= 01111000 & set char%no%=x
IF %let1%==Y set var%no%= 01011001 & set char%no%=Y
IF %let1%==y set var%no%= 01111001 & set char%no%=y
IF %let1%==Z set var%no%= 01011010 & set char%no%=Z
IF %let1%==z set var%no%= 01111010 & set char%no%=z
:: Numeric
IF %let1%==1 set var%no%= 00110001 & set char%no%=1
IF %let1%==2 set var%no%= 00110010 & set char%no%=2
IF %let1%==3 set var%no%= 00110011 & set char%no%=3
IF %let1%==4 set var%no%= 00110100 & set char%no%=4
IF %let1%==5 set var%no%= 00110101 & set char%no%=5
IF %let1%==6 set var%no%= 00110110 & set char%no%=6
IF %let1%==7 set var%no%= 00110111 & set char%no%=7
IF %let1%==8 set var%no%= 00111000 & set char%no%=8
IF %let1%==9 set var%no%= 00111001 & set char%no%=9
IF %let1%==0 set var%no%= 00110000 & set char%no%=0
IF %let1%==- set var%no%= 00100000 & set char%no%=
:: Check if done
IF %let1%== ~ goto exit2
IF %let1%== ~ goto exit2
IF %charamount%==0 goto charactersfinished
goto encode
:exit2
Echo Enter your filename
set /p "filename=>"
echo !var1!!var2!!var3!!var4!!var5!!var6!!var7!!var8!!var9!!var10!!var11!!var12!!var13!!var14!!var15!!var16!!var17!!var18!!var19!!var20!!var21!!var22!!var23!!var24!!var25!!var26!!var27!!var28!!var29!!var30!!var31!!var32!!var33!!var34!!var35!!var36!!var37!!var38!!var39!!var40!!var41!!var42!!var43!!var44!!var45!!var46!!var47!!var48!!var49!!var50!!var51!!var52!!var53!!var54!!var55!!var56!!var57!!var58!!var59!!var60!!var61!!var62!!var63!!var64!!var65!!var66!!var67!!var68!!var69!!var70!!var71!!var72!!var73!!var74!!var75!!var76!!var77!!var78!!var79!!var80!!var81!!var82!!var83!!var84!!var85!!var86!!var87!!var88!!var89!!var90!!var91!!var92!!var93!!var94!!var95!!var96!!var97!!var98!!var99!!var100!!var101!!var102!!var103!!var104!!var105!!var106!!var107!!var108!!var109!!var110!!var111!!var112!!var113!!var114!!var115!!var116!!var117!!var118!!var119!!var120!!var121!!var122!!var123!!var124!!var125!!var126!!var127!!var128!!var129!!var130!!var131!!var132!!var133!!var134!!var135!!var136!!var137!!var138!!var139!!var140!!var141!!var142!!var143!!var144!!var145!!var146!!var147!!var148!!var149!!var150!!var151!!var152!!var153!!var154!!var155!!var156!!var157!!var158!!var159!!var160!!var161!!var162!!var163!!var164!!var165!!var166!!var167!!var168!!var169!!var170!!var171!!var172!!var173!!var174!!var175!!var176!!var177!!var178!!var179!!var180!!var181!!var182!!var183!!var184!!var185!!var186!!var187!!var188!!var189!!var190!!var191!!var192!!var193!!var194!!var195!!var196!!var197!!var198!!var199!!var200!!var201!!var202!!var203!!var204!!var205!!var206!!var207!!var208!!var209!!var210!!var211!!var212!!var213!!var214!!var215!!var216!!var217!!var218!!var219!!var220!!var221!!var222!!var223!!var224!!var225!!var226!!var227!!var228!!var229!!var230!!var231!!var232!!var233!!var234!!var235!!var236!!var237!!var238!!var239!!var240!!var241!!var242!!var243!!var244!!var245!!var246!!var247!!var248!!var249!!var250!!var251!!var252!!var253!!var254!!var255!!var256!!var257!!var258!!var259!!var260!!var261!!var262!!var263!!var264!!var265!!var266!!var267!!var268!!var269!!var270!!var271!!var272!!var273!!var274!!var275!!var276!!var277!!var278!!var279!!var280!!var281!!var282!!var283!!var284!!var285!!var286!!var287!!var288!!var289!!var290!!var291!!var292!!var293!!var294!!var295!!var296!!var297!!var298!!var299!!var300!!var301!!var302!!var303!!var304!!var305!!var306!!var307!!var308!!var309!!var310!!var311!!var312!!var313!!var314!!var315!!var316!!var317!!var318!!var319!!var320!!var321!!var322!!var323!!var324!!var325!!var326!!var327!!var328!!var329!!var330!!var331!!var332!!var333!!var334!!var335!!var336!!var337!!var338!!var339!!var340!!var341!!var342!!var343!!var344!!var345!!var346!!var347!!var348!!var349!!var350!!var351!!var352!!var353!!var354!!var355!!var356!!var357!!var358!!var359!!var360!!var361!!var362!!var363!!var372!!var373!!var374!!var375!!var376!!var377!!var378!!var379!!var380!!var381!!var382!!var383!!var384!!var385!!var386!!var387!!var388!!var389!!var390!!var391!!var392!!var393!!var394!!var395!!var396!!var397!!var398!!var399!!var400!!var401!!var402!!var403!!var404!!var405!!var406!!var407!!var408!!var409!!var410!!var411!!var412!!var413!!var414!!var415!!var416!!var417!!var418!!var419!!var420!!var421!!var422!!var423!!var424!!var425!!var426!!var427!!var428!!var429!!var430!!var431!!var432!!var433!!var434!!var435!!var436!!var437!!var438!!var439!!var440!!var441!!var442!!var443!!var444!!var445!!var446!!var447!!var448!!var449!!var450!!var451!!var452!!var453!!var454!!var455!!var456!!var457!!var458!!var459!!var460!!var461!!var462!!var463!!var464!!var465!!var466!!var467!!var468!!var469!!var470!!var471!!var472!!var473!!var474!!var475!!var476!!var477!!var478!!var479!!var480!!var481!!var482!!var483!!var484!!var485!!var486!!var487!!var488!!var489!!var490!!var491!!var492!!var493!!var494!!var495!!var496!!var497!!var498!!var499!!var500! >> %filename%.txt
Echo Completed...
pause
cls
goto begin
:decode
cls
echo.The code must be on one line of the .txt document
echo.
echo File name(No extension)
set /p FileName=">
if not exist "%FileName%.txt" (
echo.No such file exists, %Filename%.txt
pause
goto decode
)
Set /p binary=<%Filename%.txt
Set binary=%binary%xxxxxxxx
Set AODL=0
SET conversion=
:decodeloop
CLS
Echo Working...
Set /a AODL=%AODL%+1
Set binary=%binary:~1%
SET TD=%binary:~0,8%
IF "%TD%" == "xxxxxxxx" Goto :EXITDECODELOOP
if "%TD%" == "01011010" set DL%AODL%=Z
if "%TD%" == "01011001" set DL%AODL%=Y
if "%TD%" == "01011000" set DL%AODL%=X
if "%TD%" == "01010111" set DL%AODL%=W
if "%TD%" == "01010110" set DL%AODL%=V
if "%TD%" == "01010101" set DL%AODL%=U
if "%TD%" == "01010100" set DL%AODL%=T
if "%TD%" == "01010011" set DL%AODL%=S
if "%TD%" == "01010010" set DL%AODL%=R
if "%TD%" == "01010001" set DL%AODL%=Q
if "%TD%" == "01010000" set DL%AODL%=P
if "%TD%" == "01001111" set DL%AODL%=O
if "%TD%" == "01001110" set DL%AODL%=N
if "%TD%" == "01001101" set DL%AODL%=M
if "%TD%" == "01001100" set DL%AODL%=L
if "%TD%" == "01001011" set DL%AODL%=K
if "%TD%" == "01001010" set DL%AODL%=J
if "%TD%" == "01001001" set DL%AODL%=I
if "%TD%" == "01001000" set DL%AODL%=H
if "%TD%" == "01000111" set DL%AODL%=G
if "%TD%" == "01000110" set DL%AODL%=F
if "%TD%" == "01000101" set DL%AODL%=E
if "%TD%" == "01000100" set DL%AODL%=D
if "%TD%" == "01000011" set DL%AODL%=C
if "%TD%" == "01000010" set DL%AODL%=B
if "%TD%" == "01000001" set DL%AODL%=A
if "%TD%" == "01111010" set DL%AODL%=z
if "%TD%" == "01111001" set DL%AODL%=y
if "%TD%" == "01111000" set DL%AODL%=x
if "%TD%" == "01110111" set DL%AODL%=w
if "%TD%" == "01110110" set DL%AODL%=v
if "%TD%" == "01110101" set DL%AODL%=u
if "%TD%" == "01110100" set DL%AODL%=t
if "%TD%" == "01110011" set DL%AODL%=s
if "%TD%" == "01110010" set DL%AODL%=r
if "%TD%" == "01110001" set DL%AODL%=q
if "%TD%" == "01110000" set DL%AODL%=p
if "%TD%" == "01101111" set DL%AODL%=o
if "%TD%" == "01101110" set DL%AODL%=n
if "%TD%" == "01101101" set DL%AODL%=m
if "%TD%" == "01101100" set DL%AODL%=l
if "%TD%" == "01101011" set DL%AODL%=k
if "%TD%" == "01101010" set DL%AODL%=j
if "%TD%" == "01101001" set DL%AODL%=i
if "%TD%" == "01101000" set DL%AODL%=h
if "%TD%" == "01100111" set DL%AODL%=g
if "%TD%" == "01100110" set DL%AODL%=f
if "%TD%" == "01100101" set DL%AODL%=e
if "%TD%" == "01100100" set DL%AODL%=d
if "%TD%" == "01100011" set DL%AODL%=c
if "%TD%" == "01100010" set DL%AODL%=b
if "%TD%" == "01100001" set DL%AODL%=a
if "%TD%" == "00110001" set DL%AODL%=1
if "%TD%" == "00110010" set DL%AODL%=2
if "%TD%" == "00110011" set DL%AODL%=3
if "%TD%" == "00110100" set DL%AODL%=4
if "%TD%" == "00110101" set DL%AODL%=5
if "%TD%" == "00110110" set DL%AODL%=6
if "%TD%" == "00110111" set DL%AODL%=7
if "%TD%" == "00111000" set DL%AODL%=8
if "%TD%" == "00111001" set DL%AODL%=9
if "%TD%" == "00110000" set DL%AODL%=0
if "%TD%" == "00101101" set DL%AODL%=-
if "%TD%" == "00100000" set DL%AODL%=
Set binary=%binary:~9%
SET conversion=%conversion%!DL%AODL%!
Goto :decodeloop
:EXITDECODELOOP
CLS
if Exist %FileName%-Decoded.txt del %FileName%-Decoded.txt
echo.%conversion% >%FileName%-Decoded.txt
echo.Translated!
ping -n 2 antonie-pc>nul
start %FileName%-Decoded.txt
echo.
pause >nul
goto begin

:charactersfinished
ping -n 1 antonie -pc>nul
cls
echo You have reached your character limit of 500!
echo The code you entered will now be translated to binary...
pause
goto exit2

Just copy and pase all that into Notepad and save it with a .bat or .cmd extension.
Tell me what you think!


Report •

#6
December 9, 2011 at 01:12:09
Second random musing. Why are people so intent on trying to do in batch things that are trivial in other scripting and/or programming languages? In most proper languages this would take just a few simple lines of code.

Report •

#7
December 9, 2011 at 02:52:04
Exactly, batch is the underdog of the Programming world. A true master of programming would know that in batch it is much harder to do stuff that are otherwise easy in other languages. Batch is the language of troubleshooting, but us masters have always found a way to have fun with batch. C++ would not work if there are significant issues with your PC and you cant actually troubleshoot your PC with C++, C, C#, Python, Java, HTML, JavaScript, ect.
Here is a challenge: try building my Text 2 Binary converter exactly the way it is in batch, in C++ eg. Now it is in batch, build an exact replica of it with C++

Report •

#8
December 9, 2011 at 03:55:27
C++ would not work if there are significant issues with your PC and you cant actually troubleshoot your PC with C++, C, C#, Python, Java, HTML, JavaScript, ect.
What? A compiled C / C++ program takes significantly less infrastructure than batch, and C / C++ / assembly is responsible for building that infrastructure. Don't be intimidated by better languages.

How To Ask Questions The Smart Way


Report •

#9
December 9, 2011 at 05:04:30
As Razor says, the situation is exactly the opposite of what you suppose. Do you think Windows is written in batch or in C? I can write a C program (or, even better, an assembler one) that will boot a PC that has no software installed on it, and make it do useful things. Can you do that with a batch program.

Why would I write a C program that copied your batch one? I'd write half-a-dozen lines of code that did the job elegantly and efficiently.


Report •

#10
December 11, 2011 at 09:48:18
OK OK, I see your point. Now make all this you are talking about:
1. ijack - I can write a C program (or, even better, an assembler one) that will boot a PC that has no software installed on it, and make it do useful things.

2. Razor2.3 - Build my translator and show me the script, you have 3 days. And show me how much easier is is in C++ than Batch. Start NOW!

3. ijack - Oh and.....I am still waiting.


Report •

#11
December 14, 2011 at 08:49:57
Really? Issue a timed challenge when I'm not around?

The end of the year work at work and the standard Christmas work outside of work has left me with very little time to myself. Add to that my crippling addiction to Skyrim, and we'll see if I can't find a few minutes to be bothered to win a pointless argument on the Internet.
It's pointless because you're not looking for the truth, you're looking to prove yourself right.

How To Ask Questions The Smart Way


Report •

#12
December 14, 2011 at 10:07:06
yea you are right, I found out that C or C++ and other programming languages are what control batch and what make it work so I ADMIT: " BATCH IS NO MATCH FOR ANY OTHER PROGRAMMING LANGUAGE" You win and sorry about the hole challenge thing.

Report •

#13
December 16, 2011 at 14:55:53
Hitman7987: I ADMIT: " BATCH IS NO MATCH FOR ANY OTHER PROGRAMMING LANGUAGE"
Now that ain't true. Windows command script is good at what it's designed to do. Namely enter a series of commands reliably and light file system manipulation. Trying to make a "real" program like what you're doing only makes it harder on yourself.

Thankfully, things are finally starting to die down at work, so I had half an hour. Here's your C++. It reeks of no effort, but I don't care. It fixes a few of your bugs and probably introduces others, but meh. Don't say I've never done anything tofor you:

#include<iostream>
#include<string>

using std::cin;
using std::cout;
using std::cerr;
using std::string;

void encode() {
  cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
  string input;
  cout << "Enter string to convert to \"binary.\"\n> ";
  std::getline(cin, input);
  for (string::iterator c = input.begin(); c < input.end(); ++c) {
    for (int i = 8; i--;)
      cout << (*c >> i & 1);
    cout << ' ';
  }
}

void decode() {
  cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
  string input;
  cout << "Enter \"binary.\" to convert.\n> ";
  std::getline(cin, input);
  int i = 0;
  char out = 0;
  for (string::iterator in = input.begin(); in < input.end(); ++in) {
    switch (*in) {
    case '1':
    case '0':
      out = (out << 1) | (*in == '1' ? 1 : 0);
      i = (i + 1) % 8;
      if (i == 0) {
        cout << out;
        out = 0;
      }
      break;
    case ' ':
    case '\t':
      if (i == 0) 
        break;
    default:
      //If we're here, it's because we got something that isn't 0/1/whitespace,
      //or we got a grouping of digits not a multiple of 8.
      std::cerr << "\nSomething's wrong with your \"binary.\"\n";
      return;
    }
  }
}

int main() {
  char in = 0;
  do {    
    if (in == '1') encode();
    else if (in == '2') decode();
    cout << "\n\n\nMenu:\n"
      << "1.\tEncode\n"
      << "2.\tDecode\n"
      << "3.\tExit\n\n"
      << "> ";
  } while(cin >> in && in != '3');
  return 0;
}

How To Ask Questions The Smart Way


Report •

#14
December 18, 2011 at 01:15:50
thanks man, you are a good programmer. And dont worry now i know c++ is better for programing needs!

Report •

Ask Question