English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

My MS-DOS knowledge isn't quite as sharp as I would like it to be, so I need a bit of help with this simple batch file for my own learning.

The batch file must look in the file "EXAMPLE.DAT" and then echo the first line of text from it (which happens to be the only text in it, if that helps) and echo it into the file "OUTPUT.DAT".

I suspect it would be only one or two lines of code, which at some point says something like "echo SOMETHING >> output.dat".

Could answerers please put the working code and if possible an explanation of the code they used into their answers. Thanks.

2006-09-16 05:15:41 · 4 answers · asked by Rich 5 in Computers & Internet Programming & Design

4 answers

Try using the TYPE command with redirection or the MORE command. You can also use HELP to find out more.

2006-09-16 05:28:11 · answer #1 · answered by Anonymous · 0 0

"copy example.dat output.dat" is the simplest way to do this. you could also do "type example.dat > output.dat" but that's more cumbersome.
copy copies a file or the console
type copies a file to the screen - the > redirects to a file
echo puts text or variables onto the screen - you can also redirect this to a file.

2006-09-16 05:21:15 · answer #2 · answered by sethsdadiam 5 · 0 0

in your "test.bat" file you must have something like:

type example.dat > output.dat

the ">" will redirect the type result to the output.dat. Beware if you are using >> instead of >. >> will append the result to the existing file content(if output.dat allready exists) so if you will do this more than once, output.dat will grow in size.

2006-09-16 06:59:10 · answer #3 · answered by None A 3 · 0 0

might be more sensible to use windows scripting (WSH) you can do all manner of file processign and other work without too much pain

dos batch was OK, but hard to do more than basic stuff

WSH has easy file handling and reading

I think yuou can use VB Script or C# to do the actual work

2006-09-16 05:34:23 · answer #4 · answered by Mark J 7 · 0 0

fedest.com, questions and answers