【发布时间】:2016-05-02 12:38:29
【问题描述】:
我写批处理文件,我有一个问题:
我希望它写入从当前日期到文件末尾的所有行
文本文件示例:
not copy this line.
not copy this line.
not this line.
5/02/2016 10 20 30 45 05 56 70 (from here )
5/03/2016 10 20 30 45 05 56 70
5/04/2016 10 20 30 45 05 56 70
5/05/2016 10 20 30 45 05 56 70
我的代码:
@ECHO OFF
set filename=abc.txt
set filename2=outFile.txt
set find=find.txt
set sourceFolder=c:\1\
IF EXIST "%find%" DEL "%find%"
IF EXIST "%filename2%" DEL "%filename2%"
IF EXIST "SAMPLE_text01.txt" DEL "SAMPLE_text01.txt"
set currentdate=%date%
set newdate=%currentdate:~5,11%
echo %newdate% >> %sourceFolder%%find%
findstr /g:%sourceFolder%%find% %sourceFolder%%filename% > %sourceFolder%%filename2%
set count=0
for /f "tokens=*" %%i in ('findstr /g:%sourceFolder%%find%
"%sourceFolder%%filename%"') do (
rem echo count is %count%
set /a count+=1
echo.%* >> temp.txt
)
pause
【问题讨论】:
-
你的代码有什么问题?显示它所有的行?没有?
-
所以,您的目标是跳过源文本文件中的前 3 行,并将其余部分复制到另一个文件中???
-
在我看来,他的目标是跳过日期 n 行。
-
嗨,你能帮我处理这段代码吗,我希望它找到今天的日期并从那里复制到文件末尾。这批只取今天的日期并停止/
-
您好,谢谢。我希望它找到今天的日期,然后从那里复制到 eof
标签: file batch-file