Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi! I would like to read file contents from a text file and display it using a batch loop. I had try this method but it seem like did not work.
for /F "delims=" %%a in ("fileL.txt") do ( @echo %%a )

If your file name doesn't contain a space then simply drop the quotes from the file name like so:
for /F "delims=" %%a in (fileL.txt) do (@echo %%a)
If the file name does contain a space then you will need to use the "usebackq" option, otherwise the filename will be parsed as a text string. An example:
for /F "usebackq delims=" %%a in ("file name with spaces.txt") do (@echo %%a)File names without spaces will also work with usebackq, even if the are contained in double quotes. See: for /? for more info.
[Edit]
Provided it contains at least 3 characters that are not spaces you could also use short (8.3) file name aliases for file names containing space(s), like so:
for /F "delims=" %%a in (filena~1.txt) do (@echo %%a)

If you do not need to parse the text from the file, why do you not just type
type file.txt or type file.txt | more ?
Using a For /F loop is to make complex easy jobs.

"it seem like did not work."
not helpful
=====================================
If at first you don't succeed, you're about average.M2

R37R0,
for sake of correctness I have to point out what you post is absolutely wrong.
The echo command to display messages on the screen is alway enabled and the @ prefix does just suppress the echoing of the command line NOT its result.
Try to believe.

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |