Home > OS >  For help, bat script, will be a string of each file, file name for the part replacement, the problem
For help, bat script, will be a string of each file, file name for the part replacement, the problem

Time:09-29

@ Echo Off
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 down
Set 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:

refer to the second floor jinsenhome response:
suggest you track down
Set 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?

TableName no problem, the third step out, that step to replace, obtain the tableName values are not correct, this itself is variable delay, don't know how to quote
  • Related