windowscmdclipboardcopy-paste

How can you get the clipboard contents with a Windows command?


For example, I can copy a file to the clipboard like this:

clip < file.txt

(Now the contents of file.txt is in the clipboard.)

How can I do the opposite:

???? > file.txt

So that the contents of the clipboard will be in file.txt?


Solution

  • You can use the paste.exe software in order to paste text just like you are describing.

    http://www.c3scripts.com/tutorials/msdos/paste.html

    With it you can do:

    paste | command
    

    to paste the contents of the windows clipboard into the input of the specified command prompt

    or

    paste > filename
    

    to paste the clipboard contents to the specified file.