Last active
August 29, 2015 14:13
-
-
Save radjivF/659f6fa80488ee3e3e2c to your computer and use it in GitHub Desktop.
update a lot of Json files in a folder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Dependancies: npm install -g jsonfile fs | |
var fs = require('fs'); | |
var jsonFile = require('jsonfile'); | |
//update | |
var dirFolder= 'TODO'; | |
var poop = "TODO"; | |
var jsonFileList = fs.readdirSync(dirFolder); | |
console.log('list of files in the folder: '+ jsonFileList) | |
console.log('we found '+ jsonFileList.length +' files') | |
for(var i=0 ;i<jsonFileList.length; i++){ | |
json = JSON.parse(fs.readFileSync(dirFolder+ jsonFileList[i])); | |
json.key = poop; | |
jsonFile.writeFileSync(dirFolder+jsonFileList[i], json); | |
console.log('Update of ' + jsonFileList[i] + ' =====> done'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment