本文介绍了批处理文件删除文本文件的前 3 行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
正如标题所述,我需要一个批处理文件来删除文本文件的前 3 行.
As the title states I need a batch file to delete the FIRST 3 lines of a text file.
例如:
A
B
C
D
E
F
G
在本例中,我需要将 A、B 和 C 与行一起删除
in this example I need A,B and C deleted along with the line
推荐答案
应该这样做
for /f "skip=3 delims=*" %%a in (C:file.txt) do (
echo %%a >>C:
ewfile.txt
)
xcopy C:
ewfile.txt C:file.txt /y
del C:
ewfile.txt /f /q
这将重新创建文件并删除前 3 行.
That will re-create the file with the first 3 lines removed.
为了让用户保持最新状态,您可以在批处理文件中以 vbscript 样式集成消息或在命令提示符中输出消息.
To keep the user updated you could integrate messages in the batch file in vbscript style or output messages in the command prompt.
@echo off
echo Removing...
for /f "skip=3 delims=*" %%a in (C:file.txt) do (
echo %%a >>C:
ewfile.txt
) >nul
echo Lines removed, rebuilding file...
xcopy C:
ewfile.txt C:file.txt /y >nul
echo File rebuilt, removing temporary files
del C:
ewfile.txt /f /q >nul
msg * Done!
exit >nul
希望这会有所帮助.
这篇关于批处理文件删除文本文件的前 3 行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!