Are these files layed out as one line for each variable/value? Are the files separate meaning that the first line with pushstring "costs" or pushstring "repairTime" would never be in same file?

If the answers are yes than I would read the folders and files as sequential data and either create new files or rewrite the lines updating the line based on your criteria and what is in the first line.