![](/img/trans.png)
[英]BATCH - Find string in text file and add a new string after that line
[英]Batch - Find string in text file and delete full line
我使用了這個 Thread 中的腳本接受了 Mofi 的答案。 腳本復制文件夾並將它們存儲在文本文件中,以在下次運行時排除一次復制的文件夾。
有時我有名為[incomplete]-different.names
文件夾,我不想復制這些文件夾。 我希望所有帶有字符串[incomplete]-
和后面的名稱的文件夾都被跳過或什至不寫入文本文件%CurrentList%
以供進一步處理。
這些是我之前的嘗試,但到目前為止我無法從頂部啟動並運行腳本。 幫助會很好,並提前致謝。
嘗試 1:
for /f "delims=" [incomplete]-%%D in ("%CurrentList%") do ( set str=%%D set str=!str: =! set str=!str: %%D =! echo !str!
嘗試2:
findstr /v /b /c:"[incomplete]-"%%D" "%CurrentList%" del "%%D"
您的第二次嘗試非常接近。
如果您只想刪除 %CurrentList% 中包含字符串[incomplete]-
,您可以將findstr /v
的輸出定向到臨時文件,然后用該文件覆蓋 CurrentList。
findstr /v /c:"[incomplete]-" "%CurrentList%" >tmpList.txt
move /y tmpList.txt "%CurrentList%" >nul
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.