0

テキスト ファイルを 2 つのファイルに分割する簡単なバッチ スクリプトを探しています。テキストファイルはで区切られています

============================================================================

テキスト ファイルは次のようになります。

test
test1
test2
test5
test
test1
test2
test5
============================================================================
test
test1
test2
test5
test
test1   
4

2 に答える 2

3

これを試して:

@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?"

..出力は次のとおりです。

file.txt.new1


テスト
テスト1
テスト2
テスト5
テスト
テスト1
テスト2
テスト5

file.txt.new2


テスト
テスト1
テスト2
テスト5
テスト
テスト1
于 2013-05-17T07:14:54.987 に答える
2
@echo off
set /p file=FILE TO PROCESS : 
del /q /f out.file*
setlocal enableDelayedExpansion
set out_file_counter=1
for /f "usebackq delims=" %%L in ("%file%") do (
 set line=%%L
 if "!line:~0,5!" equ "=====" (
    set /a out_file_counter=out_file_counter+1

 ) else (
   echo !line!>>out.file.!out_file_counter!
  )
)
endlocal
于 2013-05-17T07:09:25.703 に答える