|
Prev: Replace a byte
Next: Linux distro request
From: Terence on 7 Apr 2008 23:18 Almas:- 1) Puedes utilizar un editor de texto y cambiar cualquier caracter (menos algunos en el rango #00-#1F, especialmente #1A, #0A y #0D). 2) Lo mejor es de escibir un programito para leer lineas de texto de un archivo, hacer cambios, y escribir la linea nueva a otro archivo, y repetir linea por linea. Es mas seguro. Trad: 1) You can use a text editor to change any character to any other (except for a few in the range #00-#1F), especially #1A, #0A and #0D) 2) The best ti to write a small program to a read text line, make changes, and write the new line to anther file, and repeat line by line. It's more save.
From: Herbert Kleebauer on 8 Apr 2008 05:15 almas wrote: > I can replace any byte by Space, or others particulars bytes. ( alt 168 for > example ) > Then, i can destroy all the "alt 168" found in the file > I use SREP.EXE, but it exist anothers usefull tools. > > I try to do it my self > Sure i must open the file, read it then find the byte value... i must > resize the file before saving it an close > .. but it do not works ! Then show us your code. > If some body can find an useful code, i will appr�ciate If you only want a working program, use a stream editor like sed. If you want to write such a utility yourself, use a HLL language. If you want to do some assembly programming, then writing such a program is a good idea. But then you shouldn't ask for a already written code, but do it yourself. First make a specification of the program and then start with the implementation. And if you have concrete problem, just ask here. Here is a very simple example which is written in assembly to get a very short binary which can be included in batch programs. I will not post the source code, because you will learn much more if you try it yourself. @echo off echo hD1X-s0P[kWHP0WxCSX4ax1y1ieimnfeinklddmemkjanmndnadmndnpbbn>sbs2.com echo hhpbbnpljhoxolnhaigidpllnbkdnhlkfhlflefblffahfUebdfahhfkokh>>sbs2.com echo y57/DM(a)HzPKA/PKAhbo27WD/9GUFw/XQJkHCr40(a)kMqOhfUN0Iwl5cj/e5k>>sbs2.com echo uTzj8u(a)UN8u1/2w(a)12Uyo/YkzoJpjOG/u82UNlMzj7AEAhHvDuGk/t5//lg>>sbs2.com echo RnV7LC8/ARr0902cH0o0H1hHb3s5UEtyzz8eyxOrQ7uWk/t5//o1oEB6WQF>>sbs2.com echo 3cyOGER6Mj0z@E/p4JC0H6hf(a)rF4hX@5AUQjOaFa49/2MK1/Hb2aZXloZEH>>sbs2.com echo uWk/t5//fzex5sj/0Er2s1UEl7RA8DInVE(a)EB6mGue80@u/a3gid8oCR6c@>>sbs2.com echo 12YMufjNWkPK1qHb7ahc4/AUN87BR8MKCmTL3k5kuDMKUyzD///UR5/vzf@>>sbs2.com echo /A/H(a)HB6GAGbsy6PUy1Ud/6P/z17f/8VbK9GUFkECDWEb1wQ1R3wj8u(a)Uz3>>sbs2.com echo zj8w(a)kl5cj/3(a)kl5kj/f@/Wasj/fHB1GLb2wEGR4cf//gyl7KkFf(a)A2UkmJ>>sbs2.com echo t8/0b/gt3//wyfAReXclfrO9TbsTyXc8z(a)kk2Gg/fXMV0UMV.>>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 some examples: ----------------------------------------------------- Substitutes the 2. occurrence of user by Susan ----------------------------------------------------- sbs2.com 2 "user" "Susan" <%1 >_._ if errorlevel 1 copy _._ %1 del _._ ----------------------------------------------------- Converts dos textfiles to unix textfiles ----------------------------------------------------- sbs2.com 0 "$0d" "" <%1 >_._ if errorlevel 1 copy _._ %1 del _._ ----------------------------------------------------- Converts unix textfiles to dos textfiles ----------------------------------------------------- sbs2.com 0 "$0a" "$0d$0a" <%1 >_._ if errorlevel 1 copy _._ %1 del _._ ----------------------------------------------------- echo without CRLF ----------------------------------------------------- echo set a=|sbs2.com 0 "$0d$0a" "" >_.bat ----------------------------------------------------- Remove trailing blanks from all lines ----------------------------------------------------- :start sbs2.com 0 " $0d" "$0d" <%1 >_._ if not errorlevel 1 goto ende copy _._ %1 goto start :ende del _._ ----------------------------------------------------- Remove all single CR LF (ascii text file -> WORD) ----------------------------------------------------- sbs2.com 0 "$0d$0a$0d$0a" "$0a" <%1 >_._ if errorlevel 1 copy _._ %1 sbs2.com 0 "$0d$0a" "" <%1 >_._ if errorlevel 1 copy _._ %1 sbs2.com 0 "$0a" "$0d$0a" <%1 >_._ if errorlevel 1 copy _._ %1 del _._ ----------------------------------------------------- Extract line 5-9 from a text file ----------------------------------------------------- sbs2.com 4 "$0d$0a" '" <%1 >_._ if errorlevel 1 copy _._ %1 sbs2.com 5 "$0d$0a" "$0d$0a' <%1 >_._ if errorlevel 1 copy _._ %1
From: Dirk Wolfgang Glomp on 8 Apr 2008 02:22 Am Tue, 8 Apr 2008 01:48:12 +0200 schrieb almas: > Hi every body. > > I can replace any byte by Space, or others particulars bytes. ( alt 168 for > example ) > Then, i can destroy all the "alt 168" found in the file > I use SREP.EXE, but it exist anothers usefull tools. > > I try to do it my self > Sure i must open the file, read it then find the byte value... i must > resize the file before saving it an close > .. but it do not works ! Where is the problem? > If some body can find an useful code, i will appr�ciate My part of code remove all carriage return(CR), but the file must be lesser than 64KB. SEARCH: cmp si, cx ; Ende of File? ja short ZMA cmp BYTE PTR es:[si], 0Dh jz short SCHR inc si jmp short SEARCH ;-------- SCHR: dec WORD PTR[FILEN] sub cx, si mov di, si inc si mov ds, FILSEG dec cx mov dx, si rep movsb mov ax, DATEN mov ds, ax mov si, dx mov cx, FILEN jmp short SEARCH ;------------------------------------ ZMA: Dirk
From: almas on 8 Apr 2008 15:51 Danke Dirk Hi ! I will try the solution (s) ....may be, i will have mores ideas in my head :-) Sure SREP, or others file like grep, skip, texrep are usefull, but i do prefer having a particular ( personal) solution May be the solution just remplace and destroy 1 byte... not a very long chain ascii.... ; but i just need a very small tool. Best regards Almas "Dirk Wolfgang Glomp" <dirk(a)freecrac.dyndns.org> a �crit dans le message de news: ylcqkhcohlbs.8y8o9n3h9tnw.dlg(a)40tude.net... > Am Tue, 8 Apr 2008 01:48:12 +0200 schrieb almas: > >> Hi every body. >> >> I can replace any byte by Space, or others particulars bytes. ( alt 168 >> for >> example ) >> Then, i can destroy all the "alt 168" found in the file >> I use SREP.EXE, but it exist anothers usefull tools. >> >> I try to do it my self >> Sure i must open the file, read it then find the byte value... i must >> resize the file before saving it an close >> .. but it do not works ! > > Where is the problem? > >> If some body can find an useful code, i will appr�ciate > > My part of code remove all carriage return(CR), but the file must be > lesser than 64KB. > > SEARCH: cmp si, cx ; Ende of File? > ja short ZMA > cmp BYTE PTR es:[si], 0Dh > jz short SCHR > inc si > jmp short SEARCH > ;-------- > SCHR: dec WORD PTR[FILEN] > sub cx, si > mov di, si > inc si > mov ds, FILSEG > dec cx > mov dx, si > rep movsb > mov ax, DATEN > mov ds, ax > mov si, dx > mov cx, FILEN > jmp short SEARCH > ;------------------------------------ > ZMA: > > Dirk
From: almas on 8 Apr 2008 15:55
Hi Terence. Almas is french, and do not speak Spanish. You gave a god idea. May be i can read a line of 16 bytes into SI and put the "new" line into DI register, then save each line into the new file. Best Regards Almas "Terence" <tbwright(a)cantv.net> a �crit dans le message de news: e248a415-2a76-42fd-a9a8-eade6f4684d0(a)a5g2000prg.googlegroups.com... > Almas:- > 1) Puedes utilizar un editor de texto y cambiar cualquier caracter > (menos algunos en el rango #00-#1F, especialmente #1A, #0A y #0D). > > 2) Lo mejor es de escibir un programito para leer lineas de texto de > un archivo, hacer cambios, y escribir la linea nueva a otro archivo, y > repetir linea por linea. Es mas seguro. > > Trad: > 1) You can use a text editor to change any character to any other > (except for a few in the range #00-#1F), especially #1A, #0A and #0D) > > 2) The best ti to write a small program to a read text line, make > changes, and write the new line to anther file, and repeat line by > line. It's more save. |