'Automatically generating JSON script files from file name

I'd like to use a JSON file as a template to create new JSON files with a couple of words in the script that change according to the file name.

For example, say I have a JSON file called word1.json, with a script looking like this:

filename: word1.json

script:

{
  "name": "word1",
  "annotates": "word1.wav",
  "sampleRate": 44100
}

I want to automatically generate a new JSON script for every file name I enter, for example:

filename: word2.json

script:

{
  "name": "word2",
  "annotates": "word2.wav",
  "sampleRate": 44100
}

filename: newword.json

script:

{
  "name": "newword",
  "annotates": "newword.wav",
  "sampleRate": 44100
}

and so on.

Is there some software that allows me to do it? I'm currently editing the JSON files with TextEdit - I'm not a programmer as you can probably tell, but I can use R and can do a little bit of programming there.

EDIT: I'm on MacOS

Many thanks.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source