Question

Locked

Text Wrapping and Redirection in a DOS Window

By philrunninger ·
Now I know this is just a minor annoyance, but I was wondering if anyone had an explanation for the following behavior, or if possible, a solution.

My DOS window is 200 columns wide. The following command uses all 200 columns of the window:

C>dir /w

But when I pipe the output to any other program - more (yes, I know about /p. That's not the point.), find, findstr, etc. - or when I redirect the output to a file, text wrapping takes place at column 80.

If you're wondering why I'm asking, below is a batch file called ls.cmd, which aliases 'ls' to a big hairy DIR command. I wanted the output to be stripped of everything except the files and directories, so I piped DIR through FINDSTR to remove all the junk. But the last 120 empty columns of output just drive me nuts. Jed (in the cube beside me) says I need to 'just let it go,' but I'm sure you know how that goes. Any ideas?

File: ls.cmd
@echo off
dir /ogne/w "%~1" | findstr /v "^.Volume.in.drive. ^.Volume.Serial.Number. ^.Directory.of. ^.*[0-9,].*File(s).*[0-9,].bytes$ ^.*[0-9,].*Dir(s).*[0-9,].bytes.free$ ^$"

This conversation is currently closed to new comments.

4 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Collapse -

Try this link out..............

Collapse -

I don't see that problem on my system

by neilb@uk In reply to Text Wrapping and Redirec ...

I get a sorted list of folder names in [] followed by filenames. There doesn't seem to be anything missing. Except me and the point, maybe.

I'm using a Command Window on XPSP3 which is about 230 characters wide (to test).

Collapse -

Nothing's missing, but...

by philrunninger In reply to I don't see that problem ...

I don't lose any content from the DIR command. The problem is that instead of wrapping the text at 200 characters, it is wrapped as if the window were only 80 columns wide. But this occurs only when I pipe or redirect the DIR output. (My example shows a pipe to FINDSTR.)

Collapse -

Let it go

by neilb@uk In reply to Nothing's missing, but...

It's never going to work as you want because the Dir command doesn't pass lines of text - the woidth of the screen - to FINDSTR, it passes individual directory entries so FINDSTR deals with them one at a time and the output is in the form of single entries. One column is all you're going to get.

:)

Back to Hardware Forum
4 total posts (Page 1 of 1)  

Related Discussions

Related Forums