|
Answer» Hi,
Plz anyone help me in SOLVING this...I know this is simple but I am really NEW to writing batch scripts. I am using Windows 2000 Operating system.
I have 2 files a.txt="ABCD" and b.txt="EFGH". I want to create c.txt as "ABCD EFGH". I want to merge the 2 files separated by space (and not by new line).
Regards, Moorthy. I suspect there is more to this, but for what you asked for:
Code: [Select]@echo off for /f "tokens=1*" %%x in (a.txt) do set f1=%%x for /f "tokens=1*" %%x in (b.txt) do set f2=%%x echo %f1% %f2% > c.txt
8-)THANKS for the reply. But my scenario extends in the following way:
I have many text files in my source folder. I want to take the first 2 character of the text files and to create batch file which does some COMMANDS to the source files.
Eg,
Suppose my source folder contains files like CACS01.txt, CACQ02.txt, CAMS03.txt, SFCS04.txt, SFCQ05.txt, SFMS06.txt
I have to create 2 batch files one for CA and other for SF. The batch file should contain the following commands:
For CA:
fold -w4 CACS01.txt>>converted files\CACS01.txt fold -w6 CACQ02.txt>>converted files\CACQ02.txt fold -w8 CAMS03.txt>>converted files\CAMS03.txt
Similarly, other batch file for SF.
The 'fold' command will seperate the records from the source file(which is continuous file) by the given width and populate it into the target converted file(which is organized). I mean, the records will be seperated in the converted files while it is continuous in source file.
Note that, the width varies by 4,6,8 for corresponding CS,CQ,MS(3rd and 4th character of source files). For all my CS files, the records should be seperated by width 4 For all my CQ files, the records should be seperated by width 6 For all my MS files, the records should be seperated by width 8.
Please guide me in CREATING batch files.
Regards, Moorthy.Not really sure what you're expecting, but this will do what I interpreted you wanted
Code: [Select]@echo off setlocal enabledelayedexpansion for /f "delims=, " %%i in (filename.txt) do ( set var=%%i set col12=!var:~0,2! set col34=!var:~2,2! Call :MakeFile %%i !col12! !col34! ) goto :eof
:MakeFile if %3==CS set width=4 if %3==CQ set width=6 if %3==MS set width=8 echo fold -w%width% %1^>^>converted files\%1 >> %2.bat
You can really help yourself by learning a Windows script language. VBScript and JScript are already installed on your machine. Batch coding is a command language not a programming language.
8-) Thank you for your idea.....I got the logic what I expected.......
Thanks!!!!!!!!!
|