#!/usr/bin/python2 print """ Variable Grabbler - version 1.1 -------------------------------""" # definitions import os, json, fnmatch dir = os.path.dirname(os.path.abspath(__file__)) fext = "*.php" print "Opening config file..." config = open("variable_grabbler.cfg","r") parsed = json.load(config) for x in parsed: for path, dirs, files in os.walk(dir): for fname in fnmatch.filter(files, fext): fpath = os.path.join(path, fname) file_in = open(fpath, "r") file_content = file_in.read() file_in.close() file_content = file_content.decode('utf-8').replace("%" + x + "%", parsed[x]).encode('utf-8') file_out = open(fpath, "w") file_out.write(file_content) file_out.close() config.close()