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
?
Alternatively, right-click anywhere inside the command window, select Mark from the contextual menu, use the mouse to highlight a block text and then press Enter to save it to the clipboard.
You can do this by simply typing “ | clip ” after your command. For example if you want to copy “ipconfig” output to notepad then type “ipconfig | clip” & then open a notepad window & simply paste (or Ctrl+V). Sometime these sorts of small things save your valuable time.
In Windows PowerShell, if you've used File Explorer to copy a directory to the clipboard (using the regular Copy shortcut-menu command or the Ctrl+C keyboard shortcut), you can access it as System. IO. DirectoryInfo instance by passing -Format FileDropList to Get-Clipboard .
If it would be acceptable to use PowerShell
(and not cmd
), then you can use Get-Clipboard exactly as you were looking for.
Get-Clipboard > myfile.txt
The advantage of this method is that you have nothing to install.
Note: In place of clip
you can use Set-Clipboard that has more options.
Note 2: If you really want to run it from cmd
, you can call powershell
as in the following example powershell -command "Get-Clipboard | sort | Set-Clipboard"
.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With