Sabtu, 30 April 2011

Create a Context Menu Item to Copy a List of Files to the Clipboard in Windows 7 / Vista / XP



If you’ve ever needed to create a list of files in a directory, you’ve likely used a command from the prompt to pipe the directory listing into a file… but what if you could simply right-click on or in any folder and copy a list of the files to the clipboard?
With some registry hacking and command line utilities, we can do just that… and we can even hide the menu item behind the Shift right-click menu so it doesn’t waste space unless you need to use it.
Using the Menu Item
You can hold down Shift and right-click inside any folder, including the Desktop, and you’ll see the new “Copy List to Clipboard” item.
You can also hold down the shift key and right-click on a folder, where you’ll also see the “Copy List to Clipboard” menu item:
Once you use the menu item, you should now have a list of files on the clipboard:
You’ll notice it’s a simple file list, there’s no file size or any other information displayed. You could modify the registry hack to eliminate the /b switch if you wanted to get the rest of the information.
How it Works
We’re actually doing here is creating a menu item that opens a command prompt, runs the dir /b command (for a clean directory listing), and then pipes that into the clip.exe utility built into Windows 7 and Vista.
First we browse down to the following registry key:
HKEY_CLASSES_ROOT\Folder\shell
We created the copylist key, and then the command key underneath that. The default value for copylist is set to “Copy List to Clipboard”, and then we set the default key for command to our command line: (Updated, Thanks Todd!)
cmd /c dir “%1? /b /a:-d /o:n | clip
You could use the same thing from a command prompt, or in your own scripts… just replace %1 with the directory you are trying to get a listing of.
Note: If you are using Windows XP, you can download clip.exe from Microsoft., Just save the file in the Windows directory and the rest of the hack should work for you.
Downloadable Registry Hack
Naturally, I wouldn’t make you go through all the trouble of adding those keys manually, so you can download, extract, and double-click on the CopyFileListClipboard.reg file to install. There’s also a remove script included.
Just remember: you have to hold down the shift key while right-clicking in order to see the menu.

0 komentar:

Posting Komentar

VISITORS

Flag Counter