Batch zum Auslesen einer .txt Datei in Variablen
Hallo,
habe das Forum durchforstet und leider nichts passendes gefunden!
Ich habe eine Txt datei vorliegen mit folgendem Inhalt:
Users of XXXX: (Total of 8 licenses issued; Total of 0 licenses in use)
Users of XXXX: (Total of 8 licenses issued; Total of 0 licenses in use)
Users of XXXX: (Total of 10 licenses issued; Total of 0 licenses in use)
Users of XXXX: (Total of 8 licenses issued; Total of 0 licenses in use)
.
.
Users of XXXX: (Total of 16 licenses issued; Total of 0 licenses in use)
(Insgesamt 20 Zeilen)
Nun möchte ich eine Batch erezugen die mir diese Datei einliest und jedes einzelne XXXX (Programm), die dazugehörige erste Zahl und die dazugehörige 2 Zahl als eine eigenständige Variable speichert! Und dies mit alle 20 Zeilen! Im besten Fall hätte ich also 60 Variablen
Brauche das, denn ich möchte diese dann in einer Art Log Datei als tabelle ausgeben (per Batch)
Hoffe auf euere Hilfe, denn ich bin noch recht neu bei euch!
habe das Forum durchforstet und leider nichts passendes gefunden!
Ich habe eine Txt datei vorliegen mit folgendem Inhalt:
Users of XXXX: (Total of 8 licenses issued; Total of 0 licenses in use)
Users of XXXX: (Total of 8 licenses issued; Total of 0 licenses in use)
Users of XXXX: (Total of 10 licenses issued; Total of 0 licenses in use)
Users of XXXX: (Total of 8 licenses issued; Total of 0 licenses in use)
.
.
Users of XXXX: (Total of 16 licenses issued; Total of 0 licenses in use)
(Insgesamt 20 Zeilen)
Nun möchte ich eine Batch erezugen die mir diese Datei einliest und jedes einzelne XXXX (Programm), die dazugehörige erste Zahl und die dazugehörige 2 Zahl als eine eigenständige Variable speichert! Und dies mit alle 20 Zeilen! Im besten Fall hätte ich also 60 Variablen
Brauche das, denn ich möchte diese dann in einer Art Log Datei als tabelle ausgeben (per Batch)
Hoffe auf euere Hilfe, denn ich bin noch recht neu bei euch!
Please also mark the comments that contributed to the solution of the article
Content-Key: 379383
Url: https://administrator.de/contentid/379383
Printed on: April 26, 2024 at 10:04 o'clock
2 Comments
Latest comment
@echo off
for /f "usebackq tokens=3,7,11 delims= :" %%a in ("c:\Datei.txt") do echo %%a,%%b,%%c
@echo off
set "file=C:\datei.txt"
powershell -Executionpolicy ByPass -NoProfile -Command "gc '%file%' | ?{$_ -match 'of ([^:]+).*?of (\d+).*of (\d+)'} | %%{[pscustomobject]@{Program=$matches[1];Issued=$matches[2];InUse=$matches[2]}} | ft"
Im besten Fall hätte ich also 60 Variablen
LOL