#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    8
    Rep Power
    0

    Question Find and replace a variable that is set with another variable value


    Hello all,

    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.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2012
    Posts
    837
    Rep Power
    496
    Perhaps try this under the dos command line:

    Code:
    perl -pi.bak -e "s/VALUEONE/SNAPONE/;" command_fine.dat
  4. #3
  5. !~ /m$/
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    May 2004
    Location
    Reno, NV
    Posts
    4,263
    Rep Power
    1810
    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:

    Template::Toolkit
    Last edited by keath; July 15th, 2014 at 10:36 PM.

IMN logo majestic logo threadwatch logo seochat tools logo