Saturday, March 14, 2009

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.

image

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.

image

We are done. As a consequence we can right click on a file and now do:

image

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

Saturday, March 14, 2009 7:18:35 AM (Eastern Standard Time, UTC-05:00)  #    Comments [5]  | 
 Tuesday, July 26, 2005

Tried my hand at creating some sort of a photo gallery today. I updated the old image resizing progie so that it can draw borders and respect proportion when resizing images. I also wrote a ruby script that can generate an html gallery when it is pointed at a folder that has images and a description text file.

 

Download the updated image-resizing program, source code and ruby script here. The binary is .Net 2.0 Beta2. This is the previous blog entry about the image-resizing program.

 

That said here are two galleries I have uploaded:

Marine Drive, Cochin

Golconda Fort, Hyderabad

 

It’s fun to be blogging again and its fun to have access to your machine and the web at night. I also realize that if I keep at this I am going to run out of space with my ISP and others at TMS aren’t going to be happy. I will need to solve the web space problem…
Tuesday, July 26, 2005 2:00:16 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0]  | 
 Monday, July 25, 2005

Now that I am at home I needed to start cataloging my data and getting things in order before I move on. I spent some time yesterday writing a small app to help catalog my CDs. I had a look around but most CD cataloging apps I could find were paid apps.

 

cdScan.jpg

 

CdScan scans the CDs and lets you do a simple substring search (a little like the old Winamp J option) and also gives you an explorer kind of view of your CDs.

 

Its got a nifty little auto-scan option where you can simply set it to autoscan and keep changing CDs in your drive.

 

There are a whole host of features I can think of adding, but you might want to grab hold of it and use it to catalog your Cds and maybe add a feature or two (since I am giving away source code).

 

Download Binary: cdscan_binary.zip (250.75 KB)

Download Source Code: cdscan_source.zip (268.43 KB)

This is written using .Net 2.0 Beta 2, so you need at least the Beta2 runtime to get the binary to work.

 

Here are a lot of things I can think of adding, maybe you can add them for me –

-          wildcard and regex based searching

-          a more flexible explorer view

-          save more data for an item (EXIF data, Thumbnails, Text index)

-          more intuitive UI, with some helpful text messages…

Monday, July 25, 2005 8:45:48 AM (Eastern Standard Time, UTC-05:00)  #    Comments [5]  |