![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Newbie
Join Date: Nov 2008
Posts: 21
Rep Power: 0
![]() |
Copy batch file output to text file
I've created a batch file with the following code:
xcopy f:\ c:\backupFolder /E /S /I /Y How do I code this batch file to show the DOS window copying all the files (which it does automatically) but also output that same list of files (exactly what it shows in the DOS window) to a text file in C:\backupFolder? I know how to redirect the output, but I want it to output to both places (screen and text file) without running the command twice. Thanks in advance! |
|
|
|
|
|
#2 |
|
Rather large Wolf
|
Re: Copy batch file output to text file
Maybe have it output to a buffer file, then print the contents of that file, before appending it to your record file? Though I guess you aren't immediately informed of progress if you use such means...
|
|
|
|
|
|
#3 |
|
Not a user?
Join Date: Sep 2007
Posts: 330
Rep Power: 3
![]() |
Re: Copy batch file output to text file
I haven't tested it, but I think all you need to do is to redirect your console output to a file like so:
/complete command/>>c:\backupfolder\xcopy.log Give it a try and see if that works. |
|
|
|
|
|
#4 |
|
SEXY SHOELESS GOD OF WAR!
![]() Join Date: Jun 2005
Location: Wet west coast of Canada
Posts: 1,676
Rep Power: 7
![]() |
Re: Copy batch file output to text file
@Jabo: that will preclude displaying the output to the screen (unless an error occurs, as that will probably go to
stderr instead of stdout). The OP wants to do both, and besides the buffer to file, then echo said file, I can't think of any easy choices. I suppose you could write a program to pipe XCOPY's output to, and this program would read from stdin and write to both stdout and the file you specify, but that's probably overkill for this situation.
__________________
My microwave has settings for snake, gremlin, and puppy. |
|
|
|
|
|
#5 |
|
SEXY SHOELESS GOD OF WAR!
![]() Join Date: Jun 2005
Location: Wet west coast of Canada
Posts: 1,676
Rep Power: 7
![]() |
Re: Copy batch file output to text file
For the curious:
C Syntax (Toggle Plain Text)
__________________
My microwave has settings for snake, gremlin, and puppy. |
|
|
|
|
|
#6 |
|
PFO God In Training
![]() ![]() Join Date: Jun 2005
Location: near St Louis, MO. (USA)
Posts: 1,720
Rep Power: 7
![]() |
Re: Copy batch file output to text file
The unix tee command does just what you want. Here is a windows version. Its more than likely to be implementd similar to the previously posted program.
__________________
PFO's FAQ is here |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Batch file problems | bscr | Other Scripting Languages | 1 | Jun 27th, 2008 10:08 AM |
| Help with fstream to a text file | rhm54 | C++ | 6 | Oct 22nd, 2007 9:39 PM |
| Dynamic form from text file. | randum77 | Visual Basic .NET | 4 | Apr 24th, 2007 11:39 AM |
| Adding more info to a text file without erasing | crawforddavid2006 | C# | 2 | Apr 11th, 2007 2:10 PM |
| Change the name of output file | jazz | C | 4 | Jun 28th, 2006 2:54 AM |