| 1. |
Solve : Redirect output? |
|
Answer» Hi,
I could have made this clearer echo hello world >output.txt is equivalent to echo hello world 1>output.txt If you do this DIR /b *.txt >output.txt you will get a list of any .txt files in the current folder into output.txt BUT if there are none, the error message file not found is output to stream 2 and appears on the screen (because you have not redirected stream 2) so you can do this valid output to one file, errors to another file: dir /b *.txt 1>textfiles.list 2>errors.txt or everything in one file dir /b *.txt > textfiles.list 2>&1 If you need to echo a string to a file, white space before the redirection symbol is important if the string is a single digit (any digit 0-9) or there might be white space then a single digit number at the end of the string: C:\>echo my age is 1>test.txt & TYPE test.txt my age is C:\>echo my age is 1 >test.txt & type test.txt my age is 1 Thus echo %var%>file.txt will NOT give the same result as echo %var% >file.txt if %var% is a digit, or ends with a space then a digit C:\>set var=8 C:\>echo %var% 8 C:\>echo %var%>test.txt ECHO is on. C:\>echo %var% >test.txt C:\> Hi, Thanks for responding to my post. But, That didn't work. I did notice there is a wrinkle to the process. I run the utility from the command window, but it opens up another DOS window and the output shows up there. I'm not sure what is going on. ThanksAh. I didn't read your first post properly. I thought it said xcopy. Now I see you are using xxcopy, (which looks like a regular console program but isn't) I suggest you study the xxcopy documentation (the chm file) (in the downloaded installation zip archive) and the FAQs on the web site especially the logging options, which look like the /Oa and /On switches. |
|