2016-08-03 15 views
-2

ich eine Datei in diesem Format mit Text haben:Textkonverter benötigen (wollen Format ändern)

Name1:Pw1 
Name2:Pw2 

... 

Und ich will in dieses Format konvertieren in:

sollte
{ 
    "AuthType": "ptc", 
    "GoogleUsername": "null", 
    "GooglePassword": "null", 
    "PtcUsername": "", 
    "PtcPassword": "" 
} 

Die name1 sein gefüllt in PtcUsername und die Pw1 in PtcPassword und so weiter!

+2

Bitte [lesen Sie] (http://stackoverflow.com/help/how-to-ask). Diese Community wird nicht nur Antworten geben. Bitte lassen Sie uns wissen, was Sie versucht haben und an welchem ​​Teil des Prozesses Sie Probleme haben. Dann können wir Ihnen helfen. – elzooilogico

+0

Es ist alles in Ordnung Kerl –

Antwort

1

als Ausgangspunkt, versuchen

@echo off 

set "output=formatted.txt" 
set "data_file=source.txt" 

copy NUL "%output%">NUL & rem create an empty file for output data 

for /f "tokens=1,2 delims=:" %%a in (%data_file%) do (
    (
    echo/{ 
    echo/ "AuthType": "ptc", 
    echo/ "GoogleUsername": "null", 
    echo/ "GooglePassword": "null", 
    echo/ "PtcUsername": "%%a", 
    echo/ "PtcPassword": "%%b" 
    echo/} 
)>>"%output%" 
) 

exit/B 
+0

Gut gemacht bro, es wirkt wie ein Charme ^^ –