Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to implement replacement text content in batch processing

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report