Computing.Net > Forums > Windows 95/98 > batch file mystery

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

batch file mystery

Reply to Message Icon

Name: Mechanix2Go
Date: January 3, 2005 at 06:46:27 Pacific
OS: w2k
CPU/Ram: PIII 933 / 256
Comment:

I put these lines in a bat:
@echo off
for %%N in (1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20) do echo %%N > pix\%%N.bmp

It doen't work.
It's sitting directly above the pix directory.

It makes one file: %N.bmp

I am totally at a loss.

FWIW, it works as expected in w2k cmd.exe box.

TIA

M2



Sponsored Link
Ads by Google

Response Number 1
Name: WhitPhil
Date: January 3, 2005 at 12:13:25 Pacific
Reply:

It's been a while, but don't you need the double pipe, to concatenate into an existing file??

Ie >> versus >


0

Response Number 2
Name: ham30
Date: January 3, 2005 at 12:20:08 Pacific
Reply:

My suspicion is that WhitPhil is correct. He always is. But just in case, the real batch file experts are in the Dos forum.


0

Response Number 3
Name: rayok123
Date: January 3, 2005 at 13:03:45 Pacific
Reply:

I agree with all of the above other than it's not called a pipe, the pipe was a vertical line with a split in the middle (to the left of the "1" key) and was used to combine more than one instruction on a line (past tense as it was dropped in win95 I think). I call ">" chevrons cos it sounds posh and makes people think I know what I am on about

Techy n Welsh


0

Response Number 4
Name: ham30
Date: January 3, 2005 at 13:35:25 Pacific
Reply:

In this case, 'Pipe' is actually the name for the action and not the symbol. In other words you are 'pipeing' the output to somewhere it doesn't normally go.


0

Response Number 5
Name: jboy
Date: January 3, 2005 at 14:41:56 Pacific
Reply:

"for.. in.. do" the set elements are usually separated by commas - never tried it without them

Single redirect > creates or overwrites the target file, double redirect >> appends to it


Drop the last year into the silent limbo of the past. Let it go, for it was imperfect, and thank God that it can go.


0

Related Posts

See More



Response Number 6
Name: Mechanix2Go
Date: January 3, 2005 at 21:36:53 Pacific
Reply:

Thanks for all that.

The vertcal bar is alive and well. I use it every day and think of it as 'pipe' but I think that's not it's name.

And the > I call redirect, but chevron is certainly more posh.

Although I'm not sure what the prob is, hence the question, I'm sure that it doesn't need the >>.

I think jboy may have the key.

But I'm almost sure I've seen bats with:

for %%C in (call del) do %%C some.bat

[no commas]

Yeah, there's plenty of smarts and experience in the DOS forum. But there's also a couple guys on the verge of a mental breakdown and I don't want to be the one to push them over the edge.

I'll let you know.


M2


0

Response Number 7
Name: jboy
Date: January 3, 2005 at 22:07:03 Pacific
Reply:

Yeah, a little research indicates that a space is enough of a delimiter.

What does the set represent? You have a directory containing files numerically named but with no extension?

Drop the last year into the silent limbo of the past. Let it go, for it was imperfect, and thank God that it can go.


0

Response Number 8
Name: Mechanix2Go
Date: January 3, 2005 at 22:21:26 Pacific
Reply:

jboy,

Purpose of the bat is create BMPs 1 through 20 (for use by another bat.)

M2


0

Response Number 9
Name: jboy
Date: January 3, 2005 at 22:44:04 Pacific
Reply:

Ah, ok.

Well, all that does is echo each numeral to the redirect, which saves it as %N.BMP

Single > causes the file to be overwritten, so the file contains the final input as text: '20'

Double >> appends, yielding a textfile containing numbers 1 through 20

This won't do what you want

Drop the last year into the silent limbo of the past. Let it go, for it was imperfect, and thank God that it can go.


0

Response Number 10
Name: Mechanix2Go
Date: January 3, 2005 at 22:52:23 Pacific
Reply:

jboy,

Yes, I know.

I just tried it with command.com in w2k and it works.

BTW, I liked you response to Manual Labor. The world is full of wingnuts.

M2


0

Response Number 11
Name: jboy
Date: January 3, 2005 at 22:59:19 Pacific
Reply:

Heh - we do get occasional wandering troll come by to try and stir things up (as if that's necessary).

Yeah - I dunno, I can't see it working in 'real' DOS using echo - different plan of attack seems needed. Been quite a while since I've used DOS 'creatively' though.


Drop the last year into the silent limbo of the past. Let it go, for it was imperfect, and thank God that it can go.


0

Response Number 12
Name: Mechanix2Go
Date: January 3, 2005 at 23:16:52 Pacific
Reply:

I'm really at a loss.

This started in response to a guy who wants to randomly select 20 BMPs.

The bat that's troubling me is simply to create a bunch of BMPs so I "have something to work with."

In w2k I just did for /L %%I in (1,1,2000)
and it cooks. But no for /L in DOS.

I guess I'll need to

for in call

But I'm amazed it doesn't work as is.


M2


0

Response Number 13
Name: Mechanix2Go
Date: January 4, 2005 at 05:05:53 Pacific
Reply:

Hi Gang,

As Pooh says, "curiouser and curiouser."

It works if I do for in call and the bat called contains:

echo %1 > 98pix\%1.bmp

As with so many things in DOS/winders, I don't know why it does, it JUST DOES.

As long as we're in this deep...

I asked the requestor if he might do it in w2k. No he can't.

But one of the really slick things built into 2k is the %random% var.

A little unscientific testing indicates that the %random% var does a pretty good job, as defined by no obvious pattern.

Question: what does 2k use to generate %random% ?

Keep it simple. I don't have a PHD in math.

TIA

M2


0

Sponsored Link
Ads by Google
Reply to Message Icon

SU-0013 Error On 95 Upgra... Windows 98 and WD120gig S...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Windows 95/98 Forum Home


Sponsored links

Ads by Google


Results for: batch file mystery

how do you make a batch file use the "enter" key www.computing.net/answers/windows-95/how-do-you-make-a-batch-file-use-the-enter-key/34074.html

Batch File To Determine Exact OS www.computing.net/answers/windows-95/batch-file-to-determine-exact-os/149442.html

batch file problems www.computing.net/answers/windows-95/batch-file-problems/116856.html