Solved Split text file to be 2 text files

September 23, 2012 at 09:34:22
Specs: Windows XP
Hi all,
I need help.
I want to split my text file become 2 files.
example :
2011
Listrik
Tabungan
Hadiah
2012
Biaya
Beban
Perkiraan

to be 2 files :
1st file :
2011
Listrik
Tabungan
Hadiah
2nd file :
2012
Biaya
Beban
Perkiraan
clue : if seach find 2012 then it will split the file before 2012 to be first text file and (2012 and after) to be the next text file.
Please advice
thanks
Alex


See More: Split text file to be 2 text files

Report •

#1
September 23, 2012 at 10:21:54
✔ Best Answer
@echo off>text1 & setlocal enabledelayedexpansion
set out=text1>text2
for /f "tokens=*" %%a in (textfil) do (
if "%%a" equ "2012" set out=text2
>>!out! echo %%a
)
::====== end
caution: files in current directory named text1 or text2 will be wiped!

Report •
Related Solutions


Ask Question