SetLocal EnableDelayedExpansion
For % % I In (*. KTR) Do (
For/F "Usebackq Delims=" % % j In (" % % ~ nxi ") Do (
Set the Str=% % j
Set the fileName=% % ~ ni
The Set tableName=! FileName: ~ 3, 4!
Set the Str=! Str: zengZhiDemo=tableName!
The Echo! Str!> New_ % % ~ nxi
)
Del % % ~ nxi & gt; Nul
Ren New_ ~ ~ nxi nxi % % % %
)
CodePudding user response:
I want to put zengZhiDemo strings in each file, replace with the file name in the third to 4 as a string, find replacement, Str is variable, the tableName is variable, Set the Str=! Str: zengZhiDemo=tableName! There is something wrong with this step,CodePudding user response:
Suggest you to track downSet the fileName=% % ~ ni
The Set tableName=! FileName: ~ 3, 4!
Set the Str=! Str: zengZhiDemo=tableName!
What if every time the value of a variable within a for loop you expected?
CodePudding user response: