Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Batch file confusion W2k.  (Read 5397 times)

0 Members and 1 Guest are viewing this topic.

AlfredO

  • Guest
Batch file confusion W2k.
« on: February 21, 2008, 02:56:32 PM »
Windows 2k Pro not updated.  Cmd.exe

A real newbie to batch scripts.  I printed the FOR loop guide and tried to follow the instructions but am bogged down on the first few lines.

The instructions show that the format is:

FOR $$variable IN (set) DO command [command parameters]

So I created a .bat file containing:

Code: [Select]
@echo off
cls

For $$a IN (eula.txt) DO echo $$a

which returned the error "$$a was unexpected at this time"

After changing the code to:

Code: [Select]
@echo off
cls

FOR /F $$a IN (eula.txt) DO echo $$a

the returned error was "IN was unexpected at this time"

Give me a clue please...



WillyW



    Specialist
  • Thanked: 29
  • Experience: Experienced
  • OS: Windows XP
Re: Batch file confusion W2k.
« Reply #1 on: February 21, 2008, 05:10:09 PM »
Windows 2k Pro not updated.  Cmd.exe

A real newbie to batch scripts.  I printed the FOR loop guide


From here? :
http://www.computerhope.com/forhlp.htm


Quote
and tried to follow the instructions but am bogged down on the first few lines.

The instructions show that the format is:

FOR $$variable IN (set) DO command [command parameters]

So I created a .bat file containing:

Code: [Select]
@echo off
cls

For $$a IN (eula.txt) DO echo $$a

which returned the error "$$a was unexpected at this time"

After changing the code to:

Code: [Select]
@echo off
cls

FOR /F $$a IN (eula.txt) DO echo $$a

the returned error was "IN was unexpected at this time"

Give me a clue please...



Start by changing the "$" signs.     I believe they should be percent  " % "  signs.

.



WillyW



    Specialist
  • Thanked: 29
  • Experience: Experienced
  • OS: Windows XP
Re: Batch file confusion W2k.
« Reply #2 on: February 21, 2008, 05:10:59 PM »
I see that was your first post.       Welcome to Computer Hope!    :D
.



AlfredO

  • Guest
Re: Batch file confusion W2k.
« Reply #3 on: February 21, 2008, 11:34:34 PM »
Thank you for the welcome to C'Hope.

I printed the For loop guide by writing the output of For/? at the command prompt to a file then printing that. 

Ohhhh the embarrassment, it really is painful, I read the guide many times over two hours and still didn't pick the $/% swapover.   My optometrist will be getting a visit from me very shortly.

I will wait until this topic is buried a couple of pages deep before posting again.

Thanks again WillyW.

WillyW



    Specialist
  • Thanked: 29
  • Experience: Experienced
  • OS: Windows XP
Re: Batch file confusion W2k.
« Reply #4 on: February 22, 2008, 11:30:44 AM »
Thank you for the welcome to C'Hope.

I printed the For loop guide by writing the output of For/? at the command prompt to a file then printing that. 


That'll work too. 

Just wanted to be sure of what you had.... and at the same time make sure that you were aware of the great amount of very nice reference material here on CH,  for your future needs.


Quote
Ohhhh the embarrassment, it really is painful, I read the guide many times over two hours

Nah...     :D    Don't sweat it.        We've all been there.

Forums are great! .... easy way to get a second pair of eyes on your stuff.



Welcome to the human race, too!      ;D


Quote
and still didn't pick the $/% swapover.   My optometrist will be getting a visit from me very shortly.

I will wait until this topic is buried a couple of pages deep before posting again.

Thanks again WillyW.


You're very welcome.   
I'll assume this fixed it, and you're off and running.

I hope you have fun with your batch files.
Stop by whenever you like.   

.