PC Review


Reply
Thread Tools Rate Thread

Coverting file to Binary

 
 
Dhruv
Guest
Posts: n/a
 
      3rd Jun 2004
Hi, How to convert a text file to Binary? So I guess that
I can edit the escape charaters in the file to eliminate
CR (0D00) after every occurance of #.
 
Reply With Quote
 
 
 
 
Matthias Tacke
Guest
Posts: n/a
 
      3rd Jun 2004
"Dhruv" wrote:

>Hi, How to convert a text file to Binary? So I guess that
>I can edit the escape charaters in the file to eliminate
>CR (0D00) after every occurance of #.


Sorry Dhruv,
I forgot you after having tested a solution :-)

The folowing is ascci-assembler code from Herbert Kleebauer.
Some peopl might warn for security issues, but I checked it and
personall believe in theg integrity and reputation of Herbert.

Assuming your file is source.txt and output goes to dest.txt

::sbs2.bat
@echo off
echo Bj@jzh`0X-`/PPPPPPa(DE(DM(DO(Dh(Ls(L...X2Dx=>sbs2.com
echo 0DxFP,0Xx.t0P,=XtGsB4o@$?PIyU!WvX0GwUY Wv;ovBX2Gv0ExGIuht6>>sbs2.com
echo ?@}IKuNWpe~Fpe?FNHlF?wGMECIQqo{Ox{T?kPv@jeoSeIlRFD@{AyEKj@>>sbs2.com
echo iqe~1NeAyR?mHAG~BGRgB{~H?o~TsdgCYqe?HR~upkpBG?~slJBCyA?@xA>>sbs2.com
echo LZp{xq`Cs?H[C_vHDyB?Hos@QslFA@wQ~~x}viH}`LYNBGyA?@xAB?sUq`>>sbs2.com
echo LRy@PwtCYQEuFK@A~BxPtDss@fFqjVmzD@qB...Exep>>sbs2.com
echo LHsPBGyA?@xAunjzA}EKNs@CA?wQpQpKLBHv?s`WJ`LRCYyIWMJaejCksl>>sbs2.com
echo H[GyFGhHBwHZjjHeoFasuFUJeHeB?OsQH[xeHCPvqFj@oq@eNc?~}Nu??O>>sbs2.com
echo ~oEwoAjBKs?Zp`LBzHQzyEFrAWAG{EFrAqAGYwHTECIQ{coKIsaCsf{Oe~>>sbs2.com
echo CK}Ayre~CNFA{rAyEKFACrA{EKGAjbA}eKGSjNMtQFtc{OAyDGFj?{FDGQ>>sbs2.com
echo KAjNVk_OCAx@e?f{o?CosI}1EGizhljJ~H1Z...@g0x>>sbs2.com
::
:: Usage: sbs2.com NUMBER "STRING1" "STRING2" <infile >outfile
::
:: infile and outfile must be files (to allow random access), so in
:: NT/W2000/XP no pipe (program1 | sbst | program2) must be used!
:: infile and outfile must not be the same file!
::
:: Substitutes the NUMBER ocurrence of STRING1 in infile by
:: STRING2 and writes the result to outfile
::
:: You can include any character in STRING1/2 by using its
:: hex value (e.g. $0d for <CR> or $1a for EOF)
::
:: If NUMBER = 0 all STRING1 are substituted by STRING2
::
:: If an error is detected or nothing is substituted, erorrlevel=0
:: replace the original file only if errorlevel>=1 (=number of
:: substitutions).
::
:: Instead of the double quotes (") you can also use single quotes (')
:: with a different meaning for string2:
:: "string2" : normal substitution
:: 'string2" : before substitution the output file is rewinded
:: "string2' : after substitution the outputfile is closed
::
SBS.COM "$0d$0a#$0$0a" "$0d$0a#" <source.txt >dest.txt
del sbs.com

HTH


--
Greetings
Matthias________________________________________
For help on nt commands enter in a cmd window:
W2K>HH windows.chm::ntcmds.htm XP>HH ntcmds.chm
 
Reply With Quote
 
Matthias Tacke
Guest
Posts: n/a
 
      3rd Jun 2004
"Matthias Tacke" wrote:

Oops.
>SBS.COM "$0d$0a#$0$0a" "$0d$0a#" <source.txt >dest.txt

sorry missind "d" /\ $0d$0a is crlf
>del sbs.com
>
>HTH
>
>


--
Greetings
Matthias________________________________________
For help on nt commands enter in a cmd window:
W2K>HH windows.chm::ntcmds.htm XP>HH ntcmds.chm
 
Reply With Quote
 
Paul R. Sadowski
Guest
Posts: n/a
 
      4th Jun 2004
"Dhruv" <(E-Mail Removed)> wrote in message
news:180b401c449af$10ded540$(E-Mail Removed)...
> Hi, How to convert a text file to Binary? So I guess that
> I can edit the escape charaters in the file to eliminate
> CR (0D00) after every occurance of #.


Why not just open it with edit.com and do a search and replace?

edit /80 yourfile.xxx

Then do a global search and replace. In the replace dialog type in # and
ALT-13 (13 on the numeric keypad) and replace with just #

As always, make a backup of the original file first.


 
Reply With Quote
 
Dhruv
Guest
Posts: n/a
 
      4th Jun 2004
I could not understand what Matthias explained. Also I
tried Paul method and it did't workout. Firstly, I need
to open the txt file in notepad and do the "replace
all" "#cr" with "#". But I could not insert any escape
sequence for the "cr" (carriage return).

>-----Original Message-----
>"Dhruv" <(E-Mail Removed)> wrote in

message
>news:180b401c449af$10ded540$(E-Mail Removed)...
>> Hi, How to convert a text file to Binary? So I guess

that
>> I can edit the escape charaters in the file to

eliminate
>> CR (0D00) after every occurance of #.

>
>Why not just open it with edit.com and do a search and

replace?
>
>edit /80 yourfile.xxx
>
>Then do a global search and replace. In the replace

dialog type in # and
>ALT-13 (13 on the numeric keypad) and replace with just #
>
>As always, make a backup of the original file first.
>
>
>.
>

 
Reply With Quote
 
Matthias Tacke
Guest
Posts: n/a
 
      4th Jun 2004
"Dhruv" wrote:

>I could not understand what Matthias explained. Also I
>tried Paul method and it did't workout. Firstly, I need
>to open the txt file in notepad and do the "replace
>all" "#cr" with "#". But I could not insert any escape
>sequence for the "cr" (carriage return).


Copy the text following the dashed line to the clipboard, paste it
into notepad, save as file mk-sbs.bat and execute that batch.

You now have the executable file sbs2.com.

Like your suggestion when started with following arguments it will read
the file given after < and output to the file after >
and replace all crlf#crlf sequences with only crlf#

SBS.COM "$0d$0a#$0d$0a" "$0d$0a#" <source.txt >dest.txt

-----------------------------------------------------------------------
::mk-sbs2.bat
@echo off
echo sbs2.com"Bj@jzh`0X-`/PPPPPPa(DE(DM(DO(Dh(Ls(Lu(LX(LeZRR]EEEUYRX2Dx=>sbs2.com <mailornews:Bj@jzh`0X-`/PPPPPPa(DE(DM(DO(Dh(Ls(Lu(LX(LeZRR]EEEUYRX2Dx=>
echo 0DxFP,0Xx.t0P,=XtGsB4o@$?PIyU!WvX0GwUY Wv;ovBX2Gv0ExGIuht6>>sbs2.com
echo sbs2.com"?@}IKuNWpe~Fpe?FNHlF?wGMECIQqo{Ox{T?kPv@jeoSeIlRFD@{AyEKj@>>sbs2.com <mailornews:?@}IKuNWpe~Fpe?FNHlF?wGMECIQqo{Ox{T?kPv@jeoSeIlRFD@{AyEKj@>
echo sbs2.com"iqe~1NeAyR?mHAG~BGRgB{~H?o~TsdgCYqe?HR~upkpBG?~slJBCyA?@xA>>sbs2.com <mailornews:iqe~1NeAyR?mHAG~BGRgB{~H?o~TsdgCYqe?HR~upkpBG?~slJBCyA?@xA>
echo LZp{xq`Cs?H[C_vHDyB?Hos@QslFA@wQ~~x}viH}`LYNBGyA?@xAB?sUq`>>sbs2.com
echo sbs2.com"LRy@PwtCYQEuFK@A~BxPtDss@fFqjVmzD@qBEOEenU?`eHHeBCMs?FExep>>sbs2.com <mailornews:LRy@PwtCYQEuFK@A~BxPtDss@fFqjVmzD@qBEOEenU?`eHHeBCMs?FExep>
echo sbs2.com"LHsPBGyA?@xAunjzA}EKNs@CA?wQpQpKLBHv?s`WJ`LRCYyIWMJaejCksl>>sbs2.com <mailornews:LHsPBGyA?@xAunjzA}EKNs@CA?wQpQpKLBHv?s`WJ`LRCYyIWMJaejCksl>
echo H[GyFGhHBwHZjjHeoFasuFUJeHeB?OsQH[xeHCPvqFj@oq@eNc?~}Nu??O>>sbs2.com
echo ~oEwoAjBKs?Zp`LBzHQzyEFrAWAG{EFrAqAGYwHTECIQ{coKIsaCsf{Oe~>>sbs2.com
echo CK}Ayre~CNFA{rAyEKFACrA{EKGAjbA}eKGSjNMtQFtc{OAyDGFj?{FDGQ>>sbs2.com
echo sbs2.com"KAjNVk_OCAx@e?f{o?CosI}1EGizhljJ~H1ZeG}JBA~rACBMDGjjDG@g0x>>sbs2.com <mailornews:KAjNVk_OCAx@e?f{o?CosI}1EGizhljJ~H1ZeG}JBA~rACBMDGjjDG@g0x>
::
:: Usage: sbs2.com NUMBER "STRING1" "STRING2" <infile >outfile
::
:: infile and outfile must be files (to allow random access), so in
:: NT/W2000/XP no pipe (program1 | sbst | program2) must be used!
:: infile and outfile must not be the same file!
::
:: Substitutes the NUMBER ocurrence of STRING1 in infile by
:: STRING2 and writes the result to outfile
::
:: You can include any character in STRING1/2 by using its
:: hex value (e.g. $0d for <CR> or $1a for EOF)
::
:: If NUMBER = 0 all STRING1 are substituted by STRING2
::
:: If an error is detected or nothing is substituted, erorrlevel=0
:: replace the original file only if errorlevel>=1 (=number of
:: substitutions).
::
:: Instead of the double quotes (") you can also use single quotes (')
:: with a different meaning for string2:
:: "string2" : normal substitution
:: 'string2" : before substitution the output file is rewinded
:: "string2' : after substitution the outputfile is closed
::
 
Reply With Quote
 
Dhruv
Guest
Posts: n/a
 
      4th Jun 2004
Thanks Matthias. I could test it. But before implementing
it my coleague wrote some funny VB script even that also
did the job. Anyway, thanks.


>-----Original Message-----
>"Matthias Tacke" wrote:
>
>Oops.
>>SBS.COM "$0d$0a#$0$0a" "$0d$0a#" <source.txt >dest.txt

>sorry missind "d" /\ $0d$0a is crlf
>>del sbs.com
>>
>>HTH
>>
>>

>
>--
>Greetings
>Matthias________________________________________
>For help on nt commands enter in a cmd window:
>W2K>HH windows.chm::ntcmds.htm XP>HH ntcmds.chm
>.
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to change binary data buffer read from a binary file to string format Anderson Microsoft VC .NET 1 21st Jul 2006 11:35 AM
Convert binary file->utf8->binary file Joey Lee Microsoft C# .NET 2 25th Apr 2005 07:16 AM
Re: Coverting Photos to binary Mark R. Blain Microsoft Windows 2000 Registry 0 26th Mar 2004 12:36 AM
Re: Coverting Photos to binary Mark R. Blain Microsoft Windows 2000 Registry Archive 0 26th Mar 2004 12:36 AM
Re: Coverting Photos to binary Mark R. Blain Microsoft Windows 2000 Registry Archive 0 26th Mar 2004 12:36 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:46 AM.