An improved python code to apply a replacement to all *.adl files in a directory would be:
import re, os
files = os.listdir("./")
for file in files:
if ".adl" in str(file):
data = open(file).read()
o = open(file,"w")
o.write( re.sub("C0:TIM-PACIFIC_STRING","C1:FEC-34_TIME_STRING",data) )
o.close()
Of course, this entire python script can be replaced with a single sed command:
sed -i 's/C0:TIM-PACIFIC_STRING/C1:FEC-34_TIME_STRING/g' *
A more complicated script could be written which looks for key identifiers either in the file header or inside the file to determine which front end is appropriate, using a dictionary like:
dcuid_dict = {"BS":21,"PRM":37,"SRM":37,"ITMX":21,"ITMY":21,"MC1":36,"MC2":36,"MC3":36,"ETMX":24,"ETMY":26}
and then using for loops and if statements.
|