SoFunction
Updated on 2025-04-10

Implement replacement text content in batch processing

first:
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:
@echo off
set f=c:\
set f2="c:\"
for /?>%f%
if exist %f2% del %f2%
for /f "tokens=* delims=%" %%l in (%f%) do (
 set line=%%l
 set line=!line:FOR=F_O_R!
 echo !line!>>%f2%
 )
implement
All FORs are replaced with F_O_R and written to
Disadvantages: The original file () empty line cannot be read
Oh, study
First contact with variable content replacement in batch processing
                        set str=12345
                        set str=%str:234=000%
                        echo %str%
Result 10005
Guming is provided by fosjos. After the command is expanded, you can replace the text with batch processing.
The command extension is enabled by default. We just need to enable the delay variable environment extension. It can also be implemented through the command line:
start cmd /v:on /c