Firstly, it is relatively easy to write the TEE.BAT program. The only problem is that the set /p
command (used to get the output from the command) does not distinguish the end of the file from the empty line. This means that the output will be written to the first empty line (or the end of the file):
@echo off :: usage: AnyCommand | TEE filename setlocal EnableDelayedExpansion if exist %1 del %1 :nextLine set line=:EOF set /p line= if "!line!" == ":EOF" goto :eof echo(!line! echo(!line!>> %1 goto nextLine
You can check if this batch file works this way:
tee CopyOfFile.txt < File.txt
However , when this batch file is used in the way it was designed, it fails even now:
type File.txt | tee CopyOfFile.txt
The previous line sometimes works fine, and sometimes it shows and saves only the first line of the file. I have done some tests and cannot isolate the cause of the error. Perhaps someone (jeb?) Could explain what happens in this case and give a solution.
source share