2

I'd like to write simple Windows batch line - a loop that iterate through a file line by line and for each line just prints that line. Here i what a have:

for /F "usebackq tokens=*" %f in ("del.txt") do echo %f

But that outputs:

C:\Users\Darek\test2>echo f1.txt
f1.txt

C:\Users\Darek\test2>echo f3.txt
f3.txt

while i'd rather expected just:

f1.txt
f3.txt

Why does it prints also the C:\Users\Darek\test2>echo ... for each line?

0

Because you don't disable echo of commands.

Put as the first line of your script

@echo off

(@ before command is to not echo this command itself.)

2
  • Ok, got it, but now i have: for /F "tokens=*" %f in (del.txt) do if EXIST FolderA\%lf @echo "%f - OK" and i get C:\Users\Darek\test2>echo ... although the echo is disabled!
    – Daros911
    Jan 16 '21 at 14:43
  • First line of your batch file: @echo off. Second line: your command for /F "tokens=*" %%f in (del.txt) do if EXIST FolderA\%lf echo "%%f - OK".
    – MarianD
    Jan 16 '21 at 15:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.