Windows command FOR /F isn't working?

Posted by Mark Ransom on Super User See other posts from Super User or by Mark Ransom
Published on 2009-12-22T18:26:33Z Indexed on 2012/10/02 21:42 UTC
Read the original article Hit count: 124

Filed under:
|
|

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.

© Super User or respective owner

Related posts about windows-xp

Related posts about command-line