windows - How to pipe output and duplicate it to STDOUT?
2014-07
This question already has an answer here:
If you have a copy of tee
that runs on Windows, such that dir | tee NUL | clip
loads the clipboard, but doesn't display anything on the screen (behaving as you would expect dir | clip
to), try dir | tee con | clip
. (con
is short for “console”; it’s Windows’ equivalent of /dev/tty
. nul
, naturally, is Windows’ equivalent of /dev/null
.)
In Linux you have got tee
: Wikipedia - tee. You could install GNU core-utils for Windows: http://gnuwin32.sourceforge.net/packages/coreutils.htm
Example:
dir | tee clip
Should work just fine but I don't have Windows to try right now.
EDIT:
Another program - wintee You don't have to install coreutils (which I would advise to install anyway).
What I want to do seems very simple:
I have a folder in Windows containing items of various types including PDF files, TXT files, and subdirectories. I am writing a one line .bat file to pull ONLY the PDF file names into a new text file.
So far this is what I have in the .bat:
dir *.pdf /b > PDF_LIST.txt
This gives the following output in a PDF_LIST.txt file:
A.pdf
B.pdf
C.pdf
I would like to drop the ".pdf" portion of each line in the txt file, since I obviously know already that each file is in PDF format by the *.pdf parameter in my dir statement.
This would just make it easier for me to copy/paste all the file names directly from the text file into a word document for a transmittal I'm sending to my customer. If you can suggest a better or easier way to get the file list without using a batch file that would also would be helpful.
In your script:
for %%i in (*.pdf) do @echo %%~ni >> PDF_LIST.txt
Most text editors (including notepad) have find and replace. Just use it to find all ".pdf" and replace it with "". Done :)
You can set this as macro in word, as well.