2017-02-15 56 views
-2

我正在查找Windows批處理腳本命令,該命令可以從自動生成的文本文件中提取特定的數據字符串。請注意,test.txt文件中的第一行始終爲空。我只需要提取「2017/01/01-01」(從第二行)到另一個文件。 Findstr本身不能使用,因爲它總是會提取整行,而不僅僅是選定的字符串。使用批處理命令從文本文件獲取特定的字符串

例test.txt文件內容:

<empty line> 
    DateID : 2017/01/01-01  
     texttextext 
     texttextext 
     ... 

預先感謝。

回答

1

得到的DateID :第一次出現:

for /f "tokens=2 delims=:" %%a in ('type test.txt^|find "DateID : "') do (
    set dateid=%%a & goto :continue 
) 
:continue 
set dateid=%dateid:~1% 
echo %dateid% 
+0

它的作品,非常感謝。 :) –

相關問題