| 1. |
Solve : BATCH to format text in files .txt? |
|
Answer» Hello, if you have gawk for windows(see my sig) Sorry I forgot to say that I'm using W2K OS. Ty, but i can't use "gawk for windows". Quote from: SuperSteaua on July 01, 2009, 12:57:54 AM Sorry I forgot to say that I'm using W2K OS.gawk works on W2K as well. Its a matter of whether you want to download it or not. Its only a one time effort if you want to download and use it. However, if not, i have also shown you example of vbscript in the link. you can try that.heh, "I Have windows, so I can't use Gawk for windows" classic. Code: [Select]echo off setlocal enabledelayedexpansion for /f %%a in (a.txt) do ( if not !num! equ 3 (set line=!line! %%a) ELSE ( set num=0 echo !line! set line=%%a ) set /a num+=1 ) echo %line% pause C:\>type strcat.bat Code: [Select]echo off setLocal EnableDelayedExpansion set /a c=0 for /f "tokens=1-3 delims=" %%a in (strcon.txt) do ( set /a c+=1 set str!c!=%%a set Final=!str1! !str2! !str3! if !c! EQU 3 echo !Final! if !c! EQU 3 set /a c=0 && set str1= && set str2= && set str3= ) echo %Final% Output: C:\>strcat.bat 111111111 222222222 333333333 444444444 555555555 666666666 777777777 C:\> C:\>type strcon.txt 111111111 222222222 333333333 444444444 555555555 666666666 777777777 C:\> Quote from: billrich on July 01, 2009, 09:23:08 AM C:\>type strcat.batyour SCRIPT doesn't take care of more input lines.07/02/2009 : More input lines now possible. See post # 6 Bill Quote from: gh0std0g74 on July 01, 2009, 10:16:58 AM
Devcom post#5 beat me to the draw. His code is complete and nearly perfect. I'm still learning. Maybe the non Batch solutions should be on another Board? We might be overloading the newbies?I have to say that I realy can't use other STUFF than batch, because I use it on a server of an CLIENT and I can't INSTALL on it softweare without permision. And offcourse I don't have permision. Quote from: devcom on July 01, 2009, 08:45:52 AM Code: [Select]echo off This one seems to do the trick. But I didn't succeed to put the result into a result file DEVCOM if u can refine it please. As for the other program it didn't worked for me. Thank you in advance for u'r help. Code: [Select]echo off setlocal enabledelayedexpansion for /f %%a in (a.txt) do ( if not !num! equ 3 (set line=!line! %%a) ELSE ( set num=0 echo !line! >>log.txt set line=%%a ) set /a num+=1 ) echo %line% >>log.txt pause Quote from: devcom on July 02, 2009, 06:25:37 AM Code: [Select]echo off Thank you very much. It's working fine. Problem solved. |
|