我嘗試製作一個.bat文件,根據匹配條件的行數量,將空行添加到文本文件中。這是什麼:如何將命令的結果批量存儲到變量中?
@echo
SET /a maxLineas = 50
SET cantLineasDetalle="type texto.txt | find /i /c "D01" "
SET /a cantLineasAgregar = %maxLineas% - %cantLineasDetalle%
:loop
echo. >> texto.txt
set /a cantLineasAgregar-=1
if %cantLineasAgregar% GTR 0 goto loop
麻煩的是,var「cantLineasDetalle」沒有存儲我希望它做的值。
如何分配執行結果'type texto.txt |找到/我/ C「D01」'變量?
在此先感謝, 埃斯特萬。
謝謝。就在你迴應之前的幾分鐘,我已經找到了與控制檯一起玩的答案。這就是我所做的:「for/f」tokens = 3「%% G in('find/i/c」D01「C:\ texto.txt')SET SET cantLineasDetalle = %% G」但是我會用你的推薦來修改我的代碼。我真的讚賞你的答案。再次感謝。 – t3b4n 2012-01-05 20:00:57
@ t3b4n - FIND古怪:FIND搜索文件不同於FIND搜索文件。第一行生成2行:文件名,然後是count。第二隻產生計數。你可能想要第二種形式。 – dbenham 2012-01-05 20:16:40