Solved

Problem with FOR loop in Windows 7

Posted on 2014-04-11
2
371 Views
Last Modified: 2014-04-11
I have a very simple text file:
line1
line2
line3

and I am running this plain-vanilla command in a cmd window
FOR /F %i IN (textfile.txt) DO (echo okay)

This should echo the word "okay" three times. Instead it gives me absolutely nothing. Any ideas?
0
Comment
Question by:criskrit
2 Comments
 
LVL 82

Accepted Solution

by:
oBdA earned 500 total points
Comment Utility
Open the file in Notepad and click "Save as"; somewhere (depending on the version) on the "Save as" page, it'll show the file's encoding. The file is probably saved as Unicode, which can't be interpreted directly by a "for /f" loop.
Either change the encoding to ANSI and save, or use the output of "type" in the loop:
FOR /F %i IN ('type textfile.txt') DO (echo okay)

Open in new window

0
 

Author Comment

by:criskrit
Comment Utility
#@^&!&@*!(*@&^!@#%*!  --> censored to protect the innocent!

You are a genius!!!!! THANKS!!!!  :-) :-) :-) :-)
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

First some basics on Windows 7 Backup.  It has 2 components one is a file based backup which is stored in .zip files each zip is split at around 200 Megabytes and there is the Image Backup which is as the name implies a total image of the partition …
I have published numerous articles here at Experts Exchange that present programs/scripts written in a language called AutoHotkey. Each of those articles has a brief paragraph describing where to download the product and how to install it. I have al…
This Micro Tutorial will teach you how to change your appearance and customize your Windows 7 interface to your unique preference. This will be demonstrated using Windows 7 operating system.
The viewer will learn how to successfully download and install the SARDU utility on Windows 7, without downloading adware.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now