Get the App
SLTechnology News&Howtos  ›  Development  › 

How to implement replacement text content in batch processing

Shulou Source: shulou.com Published: 2022-06-03 08:36:56 11月15日 Update

Editor to share with you how to replace the text content in batch processing, I believe that most people do not know much about it, so share this article for your reference, I hope you will learn a lot after reading this article. Let's learn about it!

First of all:

Add one or two REG_DWORD values to the registry:

HKEY_LOCAL_MACHINE\ Software\ Microsoft\ Command Processor\ EnableExtensions

Or HKEY_CURRENT_USER\ Software\ Microsoft\ Command Processor\ EnableExtensions

Set the value to 1

Create a new file aaa.bat:

@ echo off

Set Functionc:\ aaa.txt

Set f2 = "c:\ aaa.bak.txt"

For /? > f%

If exist f2% del f2%

For / f "tokens=* delims=%" l in (f) do (

Set line=%%l

Set linework is available for all kinds of products.

Echo! line! > f2%

)

Execute aaa.bat

All FOR are replaced with F_O_R and written to aaa.bak.txt

Disadvantages: the original file (aaa.txt) blank line cannot be read

Oh, study.

Content substitution of variables in batch for the first time

Set str=12345

Set str=%str:234=000%

Echo str%

Result 10005

Fixed as provided by fosjos, after the command extension, you can replace the text with batch processing.

Another command extension is enabled by default, and we just need to enable the delay variable environment extension, which can also be achieved through the command line:

Start cmd / v:on / c test.bat

The above is all the content of the article "how to replace text content in batch processing". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Content text commands articles variables files learning not much two only can pass most more registry environment knowledge blank lines first time results shortcomings Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno Huawei Shulou Tech Info Linux Microsoft