July 14th, 2014, 10:48 PM
Find and replace a variable that is set with another variable value
Hope someone can help me.
I have a .bat file where a variable value is set to another variable value read from a different file.
Say for example, in a.bat NSPHOM=%VALUEONE%.Upon extraction, the %VALUEONE% is replaced with C:\Windows (So, now NSPHOM=C:\Windows). And this C:\Windows is read from another file which is the value of another variable called %SNAPONE%
Now I want to replace %VALUEONE% with the %SNAPONE% without hardcoding it since the path varies most of the time.
Note : I know how to get the SNAPONE value from the other file.
July 15th, 2014, 12:42 PM
Perhaps try this under the dos command line:
perl -pi.bak -e "s/VALUEONE/SNAPONE/;" command_fine.dat
July 15th, 2014, 11:33 PM
It appears that what you are looking for is a template processing solution. There are several available for perl. Search CPAN for your options.
Here's one as an example:
Last edited by keath; July 15th, 2014 at 11:36 PM.