Solved Batch files no longer reading files with for

March 12, 2017 at 19:36:45
Specs: Windows 10 x64
Last night i was writing up a batch file to read a list of files from a text file and then perform some operations on them. This morning, it's as if any batch file I make stops reading files

even using a test batch file like

for /f %%K in (d:\files.txt) do echo %%K

outputs nothing. files.txt is just a text file with
1
2
3
4
5
6
and it should output 1 though 6 to the console right? Well I get a blank line.

I am baffled as to how something can work, then hours later not work when nothing has been changed.


See More: Batch files no longer reading files with for

Reply ↓  Report •


#1
March 13, 2017 at 00:43:39
When you echo %%K, do you get nothing or do you get "Echo is OFF" (or ON, depending on what you set it to)?

I couldn't reproduce the error you're having, though if %%K actually contains data (doesn't output Echo is OFF) you might have some weird encoding on the input txt file?

I don't know really, I might be completely wrong. This is just kind of a shot in the dark.

Don't worry if plan A fails, there are 25 more letters in the alphabet ;)

message edited by RainBawZ


Reply ↓  Report •

#2
March 13, 2017 at 02:32:44
Turns out it was something with the encoding. How it got changed I have no idea, but I opened in Notepad++ and changed it to UTF-8 encoding and CR eol and it now works.

Reply ↓  Report •

#3
March 13, 2017 at 04:09:14
✔ Best Answer
Nice.

I had a tingly feeling that it was encoding related

Don't worry if plan A fails, there are 25 more letters in the alphabet ;)

message edited by RainBawZ


Reply ↓  Report •

Related Solutions


Ask Question