7

for ループでファイルを参照するときに空行を保持する方法を探しています。

for /f "tokens=1* delims=[" %%i in ('type "test1.txt" ^| find /v /n ""') do (
SET tmp=%%i
echo !tmp! >> test2.txt
)

実際には誰にでも効果がありますが、私に関する限り、効果はありません。たとえば、test1.txt の内容が次の場合:

Hello I come from France
I live in Paris

I'm sorry I don't know English, could we speak French please?
If it doesn't bother you

Thank you

test2.txt の結果は次のようになります。

[1 
[2 
[3 
[4 
[5 
[6 
[7 

星「*」の近くの「1」を延期すると、結果は次のようになります。

[1]Hello I come from France 
[2]I live in Paris 
[3] 
[4]I'm sorry I don't know English, could we speak French please? 
[5]If it doesn't bother you 
[6] 
[7]Thank you 

望ましい出力は次のとおりです。

Hello I come from France
I live in Paris

I'm sorry I don't know English, could we speak French please?
If it doesn't bother you

Thank you

この問題を解決するのを手伝ってくれませんか?

4

3 に答える 3