0 Pluspunkte 0 Minuspunkte

Ich habe dieses Script

@echo off

set filename=myfile.txt
set content=

for /f "usebackq delims=" %%i in ("%filename%") do (
    set "content=%%i"
)

echo File content: %content%

Die Variable content wird bei jedem Durchlauf überschrieben. Wie kann ich bei jedem Durchlauf den Inhatlt von %%i an den Inhalt von content anhängen?

Ich habe schon folgendes probiert

set "content=%%i"
set "content=!content!%%i"
set "content=%%content%%%%i"

von  

1 Antwort

0 Pluspunkte 0 Minuspunkte

Das letzte Beispiel das du versucht hast ist richtig, schreibe noch ein call davor.

@echo off 

set filename=myfile.txt
set content=

for /f "usebackq delims=" %%i in ("%filename%") do (
    call set "content=%%content%% %%i"
)

echo File content: %content%
von (716 Punkte)