例如,我可以将文件复制到剪贴板,如下所示:
clip < file.txt
(现在file.txt
的内容在剪贴板中。)
我怎么能这样做:
???? > file.txt
这样剪贴板的内容将在file.txt
中?
您可以使用paste.exe软件来粘贴文本,就像您描述的那样。
http://www.c3scripts.com/tutorials/msdos/paste.html
有了它你可以做:
paste | command
将Windows剪贴板的内容粘贴到指定命令提示符的输入中
要么
paste > filename
将剪贴板内容粘贴到指定的文件。
如果您接受使用PowerShell
(而不是cmd
),您可以完全按照您的要求使用Get-Clipboard。
Get-Clipboard > myfile.txt
此方法的优点是您无需安装任何内容。
注意:代替clip
,你可以使用有更多选项的Set-Clipboard。
注意2:如果你真的想从cmd
运行它,你可以调用powershell
,如下面的例子powershell -command "Get-Clipboard | sort | Set-Clipboard"
。
澄清@Kpym的答案:
powershell -command "Get-Clipboard" > file.txt
这直接回答了问题,而没有使用第三方工具。
有双向工作的第三方剪辑命令。
这是一个:
CLIP - Copy the specified text file to the clip board
Copyright (c) 1998,99 by Dave Navarro, Jr. ([email protected])
我在这个页面上有一对实用程序(来自Clip命令之前是Windows的一部分):
http://www.clipboardextender.com/general-clipboard-use/command-window-output-to-clipboard-in-vista
其中有两个实用程序,Clip2DOS和DOS2Clip。你想要Clip2DOS:
Clip2DOS版权所有2006 Thornsoft Development将剪贴板文本(1024字节)转储到标准输出。 用法:Clip2Dos.exe> out.txt结果:文本在文件中。限制:1024字节。许可证:免费,免费啤酒! http://www.thornsoft.com/dist/techsupport/dos2clip.zip
DELPHI SOURCE包括!
嘿,这是(Clip2DOS.dpr):
{Clip2DOS - copyright 2005 Thornsoft Development, Inc. All rights reserved.}
program Clip2Dos;
{$APPTYPE CONSOLE}
uses
Clipbrd,
ExceptionLog,
SysUtils;
var
p : Array[0..1024] of Char;
begin
try
WriteLn('Clip2DOS Copyright 2006 Thornsoft Development');
Clipboard.GetTextBuf(p,1024);
WriteLn(p);
except
//Handle error condition
on E: Exception do
begin
beep;
Writeln(SysUtils.format('Clip2DOS - Error: %s',[E.Message]));
ExitCode := 1; //Set ExitCode <> 0 to flag error condition (by convention)
end;
end
end.
使用doskey宏定义功能,您可以:
doskey unclip=(powershell -command "Get-Clipboard") $*
然后(例如)
dir/b | clip
unclip | sort/r
这是Dave Navarro的CLIP计划,正如@foxidrive的回答中提到的那样。这里有一篇文章提到:copying-from-clipboard-to-xywrite
此页面上有下载链接以及许多其他资源:http://www.lexitec.fi/xywrite/utility.html
这是下载的直接链接:“Dave Navarro,Jr。下载Clip.exe复制到剪贴板”
我知道我回答这个问题的时间已经很晚了,但你可以写:
type file.txt | clip
因此,剪贴板的内容将是file.txt的内容
这个肮脏的技巧适合我的需求,它随Windows一起提供!
notepad.exe file.txt
Ctrl + V,Ctrl + S,Alt + F,X