批处理文件编辑某个文件以添加一行。 [英] batch file to edit some file for adding one extra line.

查看:63
本文介绍了批处理文件编辑某个文件以添加一行。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何编写批处理文件来编辑扩展名为.h的文件并添加行

How to write batch file to edit files of extension .h and add line

" #include< Conio.h>"提交。

"#include<Conio.h>" to file.

 

推荐答案

这个批处理文件可以解决问题。  它将创建一个临时文件filename.h.tmp,然后将其重命名为原始文件名。  如果您已经有一个名为filename.h.tmp的文件,它将被覆盖。
This batch file should do the trick.  It will create a temporary file filename.h.tmp and then rename it to the original filename.  If you already have a file named filename.h.tmp, it will get overwritten.
@echo off
for %%f in (*.h) do (
	echo #include^<Conio.h^> > %%f.tmp
	type %%f >> %%f.tmp
	del %%f
	ren %%f.tmp %%f
)





这篇关于批处理文件编辑某个文件以添加一行。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆