2016-12-22 2 views
1

私は奇妙な問題を持っている - これが私のコードです:追加の行は、forループで読み - バッチ

for /f %%a in (D:\Balaji\filepath\output5.txt) do call :Sub1 %%a 
:Sub1 
echo file name is %1 
if exist %1 (
echo File %1 has arrived update the DB.. 
) else (
echo Waiting, no update to DB. 
echo We have to check if the SLA has breached. 
) 

ファイルoutput5.txtは、末尾のホワイトスペースや改行が含まれていませんが、私はこれを実行すると、forループの追加ラインを検出 - 出力は次のようなものです: - それはおそらく空行を読んでいるあなたは最後の2行で見ることができるように

file name is D:\folder\test.txt 
File D:\folder\test.txt has arrived update the DB.. 
file name is D:\folder\file.csv 
File D:\folder\file.csv has arrived update the DB.. 
file name is D:\folder\test1.txt 
Waiting, no update to DB. 
We have to check if the SLA has breached. 
file name is D:\folder\test2.txt 
Waiting, no update to DB. 
We have to check if the SLA has breached. 
file name is 
The syntax of the command is incorrect. 

どうすればこの問題を解決できますか? output5.txt

内容:バッチで

D:\folder\test.txt 
D:\folder\file.csv 
D:\folder\test1.txt 
D:\folder\test2.txt 

答えて

2
for /f %%a in (D:\Balaji\filepath\output5.txt) do call :Sub1 %%a 
GOTO :EOF 
:Sub1 

ラベル単に場所マーカーです。 「手続き」は終了しません。バッチは、gotoまたはexitまたはファイルの終わりに達するまで1行ずつ料金を請求します。

: - ラベルが理解され、そして

+0

おかげで非常に多くのプログラマによって挿入する必要がないので、ファイル終了する 『GO「後藤eof'コロンが必要ここでは意味します』私の愚か者はEOFを見逃す! :D – mathB

関連する問題