View Single Post
Old Nov 24th, 2006, 7:14 AM   #1
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5 Arevos is on a distinguished road
File list to clipboard

Python and Windows users may be interested in a small application I created to help me write technical documents. I found myself needing to place directory listings into a Word document, and, getting bored of redirecting dir in a command window, I wrote a small Python application and put a shortcut to it in my sendto menu:
python Syntax (Toggle Plain Text)
  1. import sys, os, win32clipboard, win32con
  2. files = os.listdir(sys.argv[1])
  3. files.sort()
  4. win32clipboard.OpenClipboard()
  5. win32clipboard.EmptyClipboard()
  6. win32clipboard.SetClipboardText(os.linesep.join(files))
  7. win32clipboard.CloseClipboard()
To put it into my sendto menu (C:\Documents and Settings\{username}\SendTo), I create a shortcut to it, and altered the target to:
C:\Python25\pythonw.exe "C:\Path\To\filelisttoclipboard.pyw"
Note that for this to run you must have Python, and the win32 Python library installed.
Arevos is offline   Reply With Quote