this may be a little Off-Topic, but...
I have to re-arrange a bunch of JSON-formatted Files. The wrong .JSON-Files begin with
Code: Select all
{
"Inventarnummer": "INV20911",
"Timecode": "noTC",
"Seite": "0",
"Digitalisierungsergebnis": "AUDIOVISUELLE_DIGITALISIERUNG",
"Dateien" :
[
{
"Dateiname": "INV20911.7z",
"Typ": "ARCHIVDIGITALISAT",
"XXHash": "95def85c"
},
{
"Dateiname": "a4871611-f849-43aa-91c5-84a0270979e6.JSON",
"Typ": "ARCHIVDIGITALISAT-ANALYSEDATEI",
"XXHash": "555e4011"
},
Code: Select all
{
"DigitalisierungsprozessID": "11111111-76cc-4cc2-aafb-7bac6b0d9281",
"Digitalisierungsergebnis": "AUDIOVISUELLE_DIGITALISIERUNG",
"Dateien" :
[
{
"Dateiname": "11111111-76cc-4cc2-aafb-7bac6b0d9281.7z",
"Typ": "ARCHIVDIGITALISAT",
"XXHash": "95def85c"
},
{
"Dateiname": "a4871611-f849-43aa-91c5-84a0270979e6.JSON",
"Typ": "ARCHIVDIGITALISAT-ANALYSEDATEI",
"XXHash": "555e4011"
},
The Problem: in Command-Executor this code works in a way that it replaces both INV*-Values but kills the file-extension ".7z" in line 6
Code: Select all
%comspec% /C "
POWERSHELL -Command (gc "%s_original_path%\archiv-import-packliste3.json")
-replace 'INV.*', '%s_original_path~1%%s_jsonquoteandcomma%' |
Out-File -encoding ASCII "%s_original_path%\archiv-import-packliste4.json"
"
Code: Select all
{
"DigitalisierungsprozessID": "11111111-76cc-4cc2-aafb-7bac6b0d9281",
"Digitalisierungsergebnis": "AUDIOVISUELLE_DIGITALISIERUNG",
"Dateien" :
[
{
"Dateiname": "11111111-76cc-4cc2-aafb-7bac6b0d9281",
"Typ": "ARCHIVDIGITALISAT",
"XXHash": "95def85c"
},
{
"Dateiname": "a4871611-f849-43aa-91c5-84a0270979e6.JSON",
"Typ": "ARCHIVDIGITALISAT-ANALYSEDATEI",
"XXHash": "555e4011"
},
- %s_jsonquoteandcomma%
- \",
- INV.*\.7z
Code: Select all
%comspec% /C "
POWERSHELL -Command (gc ""%s_original_path%\archiv-import-packliste2.json"")
-replace 'INV.*7z', '"%s_original_path~1%.7z"' | Out-File -encoding ASCII "%s_original_path%\archiv-import-packliste3.json"
"
Thanks in advance,
Thomas