分割文本文件转换成2个文件由分离器 [英] Split text file into 2 files by separator
本文介绍了分割文本文件转换成2个文件由分离器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要寻找那一刹那我的文本文件转换成两个文件一个简单的批处理脚本。该文本文件通过分离
====================================== ======================================
文本文件看起来像这样:
测试
TEST1
TEST2
TEST5
测试
TEST1
TEST2
TEST5
================================================== ==========================
测试
TEST1
TEST2
TEST5
测试
TEST1
解决方案
试试这个:
关闭@echo和放大器; SETLOCAL
设置文件= file.txt的
FOR / Fdelims = []我%%在('^<%文件%查找/ N=)并设置分裂= %%我
(FOR / F令牌= 1 * delims = []我%%在('^<%文件%查找/ N / V')做,如果我%% LSS%分割%回波(%% j)条>中的文件%%.new1
<%文件%>中的文件%%.new2更+%分割%
键入%文件%。新的?
..输出是:
file.txt.new1
测试
TEST1
TEST2
TEST5
测试
TEST1
TEST2
TEST5file.txt.new2
测试
TEST1
TEST2
TEST5
测试
TEST1
I am looking for a simple batch script that split my text file into two files. The text file is separated by with
============================================================================
Text file looks like this:
test
test1
test2
test5
test
test1
test2
test5
============================================================================
test
test1
test2
test5
test
test1
解决方案
try this:
@echo off&setlocal
set "file=file.txt"
for /f "delims=[]" %%i in ('^<"%file%" find /n "="') do set "split=%%i"
(for /f "tokens=1*delims=[]" %%i in ('^<"%file%" find /n /v ""') do if %%i lss %split% echo(%%j)>"%file%.new1"
<"%file%">"%file%.new2" more +%split%
type "%file%.new?"
..output is:
file.txt.new1 test test1 test2 test5 test test1 test2 test5 file.txt.new2 test test1 test2 test5 test test1
这篇关于分割文本文件转换成2个文件由分离器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文