subs_names.py script runs both Python 2.6+ and Python 3.x:
#!/usr/bin/env python from __future__ import print_function import sys, fileinput # here goes new values substitions = dict(TargetName=r"D:\new", FriendlyName="Big") inplace = '-i' in sys.argv # make substitions inplace if inplace: sys.argv.remove('-i') for line in fileinput.input(inplace=inplace): name, sep, value = line.partition("=") if name in substitions: print(name, sep, substitions[name], sep='') else: print(line, end='')
Example:
$ python3.1 subs_names.py input.txt InstallPrompt= DisplayLicense= FinishMessage= TargetName=D:\new FriendlyName=Big
If you are satisfied with the result, add the -i option to make changes to the location:
$ python3.1 subs_names.py -i input.txt
source share