开发者

Automated string insertion on windows

Normally I'm a mac person, but at my new job I'm finding myself using a PC. I often have to open html files and for every href link insert a target blank argument. Rather then do this manually I was wondering if there was a script that I could use to automate the process. Say:

  1. search for href
  2. find the second double quot开发者_运维知识库ation after the href string
  3. insert the string "target = _blank"

Mind you I have never used a shell script on a PC in my life, so much explanation might be needed here.

Thanks,


I use Groovy for those kind of tasks. Good thing with Groovy (as well as with other famous scripting languages), someone might have already done the task you want to accomplish. In your case, I found this article. It demonstrates a similar case you mentioned (Search and Replace).


I don't believe the windows shell is very powerful, so even if it is possible to achieve I can't imagine it'll be easy. I would strongly advise using a real scripting language such as Python or Perl, or bash if that's what you're familiar with. You can install pretty much all of them on Windows (see links).

I presume you can solve the problem from there, as your major concern seemed to be with Windows.


Just get a copy of sed for win32 (perhaps form here) and do it the usual sed way.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜