I know the title is generalized. Sorry about that.
So my problem is that when I try to read a file, I can only read one kind of them. What I mean by one kind, is that I can read only the one I create and are typed manually.
When I create a text document and type myself words in it, my loop reads and shows the lines just fine.
But when I try to read a file that has been modified through commands, more precisely with the >
and >>
operator, it doesn't do anything. Nothing displays and the script keeps on going. As if it ignores the loop.
Here is the loop I use:
for /f "delims==" %%i in (...\TEST.txt) do(
echo %%i
)
What's the problem with this? Why doesn't it read my modified files and how can solve this?
I've used these links for information:
BAT file to read and copy bottom 16 lines from a text file to another one?
CMD.EXE batch script to display last 10 lines from a txt file
Here is the code that is not "working":
wmic os get Caption > "C:\Users\%USERNAME%\Desktop\Arch.txt"
wmic OS get OSArchitecture >> "C:\Users\%USERNAME%\Desktop\Arch.txt"
for /f "delims==" %%i in (C:\Users\%USERNAME%\Desktop\Arch.txt) do (
echo %%i
)
Again, if I set a file that I've manually typed instead of Arch.txt, I will work.
Thank you for your time and patience.