Windows command FOR /F isn't working?
- by Mark Ransom
I'm trying to use the FOR command in Windows XP's command line. I have a file temp.txt with 3 lines:
temp1
temp2
temp3
And I'm typing the following command at the prompt:
for /F %p in (temp.txt) do echo Testing %p
Nothing comes back. If I remove the /F parameter, the output is Testing temp.txt.
As far as I can determine, I'm using the command exactly as it is documented by Microsoft. I've checked my registry to make sure Command Extensions are on, and even started a new shell with cmd /e:on to be doubly sure.
What am I doing wrong?
Yes, I was doing something wrong.
The file temp.txt wasn't created from scratch, I just edited it to put in my test content. Unfortunately when I created the file the first time, I saved it with a UTF-8 marker at the front. Recreating the file as plain text solved the problem.