April 7nth: Update: Clip.1.10 is posted here. See below.
April 8th: Update: Clip.1.11 is posted here. See below.
I finally scratched a long standing itch and wrote this tool. I don't understand why I didn't do this a few years back.
Clip lets you interact with the Windows clipboard from the command line. Of course, you need to do this only if you are a heavy command line user.
Clip lets you copy/move/delete files in the clipboard from the command line; you can copy and paste files between cmd shell windows and between the cmd shell and windows explorer. You can also dump clipboard data on the console (redirect it to files, if you choose) and pipe data into the clipboard. It also lets you examine various clipboard formats and such. The clip command t2f is rather handy for situations where you have a list of file names (as cut/copied text) in the clipboard and you want to perform actual file operations on them.
Finally, Vista apparently comes with a clip.exe that does very little. It might be lying in your path before my clip.exe is. Fix it by (1) renaming one of these programs OR (2) putting this program's dir before system32 in the PATH. I did the later.
Clip v1.11 - A Clipboard tool for the Command Line
March 2009 (c) Roshan James
Usage:
clip <cmd sequence>
Commands:
formats - Lists data formats currently available in the Clipboard
text - If the clipboard has text, display it
clear - Clears clipboard
in - Copies stdin to clipboard as text
put <text> - Puts text into clipboard.
flist - List files in clipboard (uses "FileDrop" format)
fcopy - Copy files in clipboard to current dir
fmove - Move files in clipboard to current dir
fdelete - Delete files in clipboard to current dir
faction <cmd> - Executes the specified command as the action.
Possible use: delegate file copy to robocopy.
files <wildcard> - Extends (uniquely) the file list in the clipboard.
cut - Sets the shell action for files to 'cut'
copy - Sets the shell action for files to 'copy'
paste,drop - Executes the current shell action, like a shell 'paste'.
display <format name>
- Displays clipboard data (if possible). Format names are those
listed by "formats" command. Use doubles quotes if format
names have spaces
t2f - Text to Files: takes the current text data in the clipboard and
converts it into a list of filenames for pasting. Each text line
is treated as a file path.
Ex: Copy file contents to clipboard.
> type test.text | clip in
Ex: Copy clipboard contents to file.
> clip text > test.txt
Ex: Put *.txt files in clipboard.
> clip files *.txt
Ex: Cuts *.txt files into the clipboard.
> clip files *.txt cut
Further, clip commands are executed in sequence. Hence we have:
Ex: Copy txt files from all subdirs to current dir.
> dir *.txt /s/b | clip in t2f fcopy
Ex: Convert clipboard content to plain text.
> clip text | clip in
Send me bugs, typos, suggestions.
Clip is written in C# and has been tested on Windows Vista; it may/should run on other windows versions where the right version of the .Net framework is installed - the 2008 version - whatever it is called. All the file operations assume a certain semantics for the "FileDrop" format of the clipboard - this could very well change between windows versions, so if you have a different windows and file operations don't work, let me know. Clip is free for use; use it at your own risk - I am not responsible for any damage caused.
April 7nth: Update: Cut, Copy, Paste...
Clip has been upgraded to version 1.10. The new commands include cut, copy and paste. "Clip files *.txt" acts like a select operation where files are added to the clipboard without specifying a shell behavior when pasting happens. On pasting the shell reverts to its default action, which is "copy". The newly added cut and copy commands lets one specify the shell action. Hence "clip files *.txt cut" will place the txt files into the clipboard with a cut action associated with them. Simply executing "clip copy" or "clip cut" will change the action for the files currently in the clipboard. The paste command acts like a shell paste - it will copy or cut/move depending on what the current action is.
April 8th: Update: Adding "Copy Path to Clipboard" in the "Send To" context menu.
Clip has a new command called put. "clip put hello" will put the string hello into the clipboard. This is handy in several instances. One of which is motivated by Jean Pierre Daviau's comment below. We can add a "Send To" shortcut in explorer to copy any file's path. Go to an explorer window and type "shell:sendto" in the address bar.
This should display a list of shortcuts that are in the default "Send To" menu. Create a new shortcut there to clip.exe and give it a nice nice name such as "Send Path to Clipboard" and then edit the shortcut to have the command line argument "put" as well.
We are done. As a consequence we can right click on a file and now do:
The above instructions are for the Vista shell.It should be easy to find the equivalent for XP as well.
Download Clip Binary
Download Clip Sources