fabian-haas
Goto Top

Doppelpunktgetrennte Textdatei einlesen Batch

Hallo,

ich habe eine Textdatei auf einem Server, die sieht so aus
z:hallo:z
z:moin:z
z:gruss-gott:z
z:wie-gehts:z
und möchte aus einer bestimmten Zeile das hallo, moin etc. einlesen und in eine andere Textdatei speichern. Bisher sieht meine Batch so aus:
set /p NS=
set /a NSTEMP=NS-1
for /f "usebackq skip=%NSTEMP%" %%i in (\\%SERVERIP%\shares\%USERNAME%.txt) do (  
       echo %%i> "%USERPROFILE%\Datei.txt"  
       )
aber wie bekomme ich das hin, dass nur das "hallo, moin etc." verwendet wird?

Vielen Dank im Vorraus
Fabian Haas

Content-Key: 229226

Url: https://administrator.de/contentid/229226

Printed on: April 24, 2024 at 19:04 o'clock

Member: Endoro
Solution Endoro Feb 09, 2014, updated at Feb 10, 2014 at 18:03:24 (UTC)
Goto Top
Hey,

so gehts:
for /f "usebackq skip=%NSTEMP% tokens=2 delims=:" %%a in ("\\%SERVERIP%\shares\%USERNAME%.txt") do echo(%%a  
Gruss.
Member: bastla
Solution bastla Feb 09, 2014, updated at Feb 10, 2014 at 18:03:30 (UTC)
Goto Top
Hallo Fabian-Haas!

Etwa so:
for /f "skip=%NSTEMP% tokens=2 delims=:" %%i in (\\%SERVERIP%\shares\%USERNAME%.txt) do (
Du solltest Dir das Tutorial zur FOR-Schleife von @Friemler ansehen ...

Grüße
bastla
Member: TsukiSan
Solution TsukiSan Feb 09, 2014, updated at Feb 10, 2014 at 18:03:34 (UTC)
Goto Top
Hallo Fabian-Haas,

eventuell nur deine Zeile 3 anpassen:
for /f "tokens=2 delims=:" %%i in (\\%SERVERIP%\shares\%USERNAME%.txt) do (echo %%i>>Datei.txt)  

Gruss
Tsuki

Ps.: Nur Dritter face-sad