[SOLVED] FFAStrans CommandExecuter with RegEx in Powershell
Posted: Tue Oct 26, 2021 9:39 am
Hi to all,
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
The Corrected .JSON has to look like this (again, only the beginning of the file, notice the correct file-extension in line 6):
So the changes are the first few lines and the Filename *.7z.
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
Outcome is (notice the missing .7z-Extension in line 6):
I had quite some trouble getting the Powershell-RegEx running. Even the escape-Characters seems to be problematic. I tried a work-around with PopulateVariables-Node to get the escape-Character working on the Powershell-Expression above. So the
the workflow is also attached, so maybe someone is able to get me back on track...?
Thanks in advance,
Thomas
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