Bat file to add new line in a certain position in all files inside a folder [closed]

江枫思渺然 提交于 2020-01-28 03:07:08

问题


I have a folder with more files .ovpn contain text

Path: D:\Program files\config

Extension files: *.ovpn

I need to add in every files a new line contains mssfix 0 in a certain position in the file

mssfix 0 will be added at line 96

or creating a new line at line before resolv-retry infinite

Result before adding:

OTHER TEXT LINES
OTHER TEXT LINES
OTHER TEXT LINES

resolv-retry infinite
nobind
persist-key
persist-tun
client
verb 3
#auth-user-pass

OTHER TEXT LINES
OTHER TEXT LINES
OTHER TEXT LINES

Result after adding:

OTHER TEXT LINES
OTHER TEXT LINES
OTHER TEXT LINES

mssfix 0
resolv-retry infinite
nobind
persist-key
persist-tun
client
verb 3
#auth-user-pass

OTHER TEXT LINES
OTHER TEXT LINES
OTHER TEXT LINES

The files contain other text but other must not be edited.

I prefer a simple batch solution to avoid external software

WARNING: this is a part of text, before and after this part of file there is other lines of text to not to be changed.

来源:https://stackoverflow.com/questions/59801460/bat-file-to-add-new-line-in-a-certain-position-in-all-files-inside-a-folder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!