清除(文本)并编辑文件夹中的所有 .json 文件

清除(文本)并编辑文件夹中的所有 .json 文件

我有一个包含大量 .json 文件的文件夹。我想用特定内容替换这些文件的内容。我可以删除所有 json 文件的所有文本:

FOR /R C:\YourFolder %%f IN (*.json) DO TYPE NUL>%%f

我可以特别写入 .json 文件:

@echo off


(echo {) > NAME.json
(echo  "parent": "minecraft:recipes/root",) >> NAME.json
(echo   "rewards": {) >> NAME.json
(echo     "recipes": [) >> NAME.json
(echo       "minecraft:stone") >> NAME.json
(echo     ]) >> NAME.json
(echo   },) >> NAME.json
(echo   "criteria": {) >> NAME.json
(echo     "impossible": {) >> NAME.json
(echo       "trigger": "minecraft:impossible") >> NAME.json
(echo     }) >> NAME.json
(echo   },) >> NAME.json
(echo     "has_the_recipe": {) >> NAME.json
(echo       "trigger": "minecraft:recipe_unlocked",) >> NAME.json
(echo       "conditions": {) >> NAME.json
(echo         "recipe": "minecraft:stone") >> NAME.json
(echo       }) >> NAME.json
(echo     }) >> NAME.json
(echo   },) >> NAME.json
(echo   "requirements": [) >> NAME.json
(echo     [) >> NAME.json
(echo       "impossible") >> NAME.json
(echo     ]) >> NAME.json
(echo   ]) >> NAME.json
(echo }) >> NAME.json
exit

但我无法将两者结合起来

抱歉,如果不太清楚的话,我不是英语:)

相关内容