import re import os import sys import shutil
if os.path.isfile(sys.argv[1] + ".bak"): os.remove(sys.argv[1] + ".bak") shutil.copy(sys.argv[1], sys.argv[1] + ".bak")
with open(sys.argv[1], 'r+') as content_file: content = content_file.read() m = re.search("VALUE \"FileVersion\", \"(([\\d]+).[ ]*)*([\\d]+)\"", content) new_ver = str(int(m.group(3)) + 1) content = re.sub("(VALUE \"FileVersion\", \"([\\d]+.[ ]*)*)[\\d]+\"", "\\g<1>" + new_ver + "\"", content)
m = re.search("FILEVERSION (([\\d]+).[ ]*)*([\\d]+)", content) new_ver = str(int(m.group(3)) + 1) content = re.sub("(FILEVERSION ([\\d]+.[ ]*)*)([\\d]+)", "\\g<1>" + new_ver, content)
m = re.search("VALUE \"ProductVersion\", \"(([\\d]+).[ ]*)*([\\d]+)\"", content) new_ver = str(int(m.group(3)) + 1) content = re.sub("(VALUE \"ProductVersion\", \"([\\d]+.[ ]*)*)[\\d]+\"", "\\g<1>" + new_ver + "\"", content)
m = re.search("PRODUCTVERSION (([\\d]+).[ ]*)*([\\d]+)", content) new_ver = str(int(m.group(3)) + 1) content = re.sub("(PRODUCTVERSION ([\\d]+.[ ]*)*)([\\d]+)", "\\g<1>" + new_ver, content) content_file.seek(0) content_file.write(content) content_file.truncate() content_file.close()
|