Replacing characters in a text file with a batch f

2020-04-05 08:11发布

Is there a way to replace some characters in a text file with a batch file?

I didn't find any command to do that.

标签: batch-file
7条回答
迷人小祖宗
2楼-- · 2020-04-05 08:43

The quick answer is "No, not with basic windows utilities"

But as the other answers suggested, there are lots of unix ports out there that do what you want. Take alook at gnuwin32 packages.

EDIT:

Okay, I revise my strict "No". There might be a way of doing it, depending on the complexity of your task and your OS. When using windows 2000 and above, cmd provides command extensions that you can use.

The basic idea is to use a FOR loop to go through each line of an input file and then to use string substitution provided by the SET command to replace your characters.

I have no solution at hand but you might try on your own, using infromation from this quite cool site. Look here for the FOR loop syntax and here for the string substitution.

查看更多
登录 后发表回答