windows - How to pipe output and duplicate it to STDOUT?

07
2014-07
  • Louis

    This question already has an answer here:

  • Answers
  • Scott

    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/ttynul, naturally, is Windows’ equivalent of /dev/null.)

  • Chris

    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).


  • Related Question

    windows - How do I hide file extensions in a command prompt /dir output?
  • NoCatharsis

    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.


  • Related Answers
  • Dennis Williamson

    In your script:

    for %%i in (*.pdf) do @echo %%~ni >> PDF_LIST.txt
    
  • Sunny

    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.