That certainly seems to work, I end up with "debug 1" to "debug 11".
It's going to take some study to try and understand what's going on.
Unfortunately I can't do a straightforward diff flows.json newflows.json because my flows.json has new lines and the new file doesn't.
I do have a working flow too, Jsonata to extract the iffy debug nodes and a sed command to edit the file. It feels like cheating to shell out to the OS, but of course the ability to do that is part of why Node-red is so useful.
I once tried to get the powers to consider building sed/awk/bash etc ability into the change node like Jsonata is, for situations like this. It didn't go down well!
[{"id":"c5f8b30b53cb1fda","type":"group","z":"cdc9555eb7388073","name":"Use jsonata to assemple a list of \"debug [0-9]{3}[0-9]*\" nodes and sed to edit them","style":{"label":true},"nodes":["203c41e8b6075f7c","8597d919d8d47788","951d72920008289f","1ef6f40a85ec11be","eb5bbc2b54cda6d6","152f43d6a8e4ba33","fc9a1b0790b3d6fa","3799d1023fc7c885","9887ed66d6f09245","772f0dbfdd07c24a","21b40b8cb56d2520","cc1e8a1c53da4cbe"],"x":14,"y":299,"w":812,"h":202},{"id":"203c41e8b6075f7c","type":"inject","z":"cdc9555eb7388073","g":"c5f8b30b53cb1fda","name":"go","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":110,"y":340,"wires":[["8597d919d8d47788"]]},{"id":"8597d919d8d47788","type":"file in","z":"cdc9555eb7388073","g":"c5f8b30b53cb1fda","name":"flows.json","filename":".node-red/flows.json","filenameType":"str","format":"utf8","chunk":false,"sendError":false,"encoding":"none","allProps":false,"x":240,"y":340,"wires":[["951d72920008289f"]]},{"id":"951d72920008289f","type":"json","z":"cdc9555eb7388073","g":"c5f8b30b53cb1fda","name":"","property":"payload","action":"","pretty":false,"x":370,"y":340,"wires":[["1ef6f40a85ec11be"]]},{"id":"1ef6f40a85ec11be","type":"change","z":"cdc9555eb7388073","g":"c5f8b30b53cb1fda","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload[type = \"debug\"][$match(name, /debug [0-9]{3}[0-9]*/)].{ \"id\": id, \"name\": name}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":340,"wires":[["152f43d6a8e4ba33","fc9a1b0790b3d6fa"]]},{"id":"eb5bbc2b54cda6d6","type":"debug","z":"cdc9555eb7388073","g":"c5f8b30b53cb1fda","name":"Result","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":730,"y":420,"wires":[]},{"id":"152f43d6a8e4ba33","type":"function","z":"cdc9555eb7388073","g":"c5f8b30b53cb1fda","name":"sed command","func":"const debugs = msg.payload\nlet cmd = \"sed -i '\"\n\nfor (var index in debugs) {\n const nn = Number(index) + 1\n debugs[index].newname = \"debug 0\" + nn\n const sub = \"s/\\\"\" + debugs[index].name + \"\\\"/\\\"\" + debugs[index].newname + \"\\\"/; \"\n cmd = cmd + sub\n}\n\ncmd += \"' .node-red/flows.json \"\nmsg.payload = cmd\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":140,"y":420,"wires":[["cc1e8a1c53da4cbe"]]},{"id":"fc9a1b0790b3d6fa","type":"debug","z":"cdc9555eb7388073","g":"c5f8b30b53cb1fda","name":"debug 2523","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":710,"y":340,"wires":[]},{"id":"3799d1023fc7c885","type":"exec","z":"cdc9555eb7388073","g":"c5f8b30b53cb1fda","command":"","addpay":"payload","append":"","useSpawn":"false","timer":"","winHide":false,"oldrc":false,"name":"Run it","x":330,"y":420,"wires":[[],[],["9887ed66d6f09245"]]},{"id":"9887ed66d6f09245","type":"switch","z":"cdc9555eb7388073","g":"c5f8b30b53cb1fda","name":"rc == 0?","property":"payload.code","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":460,"y":420,"wires":[["772f0dbfdd07c24a"],["21b40b8cb56d2520"]]},{"id":"772f0dbfdd07c24a","type":"change","z":"cdc9555eb7388073","g":"c5f8b30b53cb1fda","name":"Restart","rules":[{"t":"set","p":"payload","pt":"msg","to":"Now restart Node-Red and reload the page","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":600,"y":400,"wires":[["eb5bbc2b54cda6d6"]]},{"id":"21b40b8cb56d2520","type":"change","z":"cdc9555eb7388073","g":"c5f8b30b53cb1fda","name":"Error","rules":[{"t":"set","p":"payload","pt":"msg","to":"Something went wrong!","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":590,"y":440,"wires":[["eb5bbc2b54cda6d6"]]},{"id":"cc1e8a1c53da4cbe","type":"debug","z":"cdc9555eb7388073","g":"c5f8b30b53cb1fda","name":"debug 2525","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":270,"y":460,"wires":[]}]