Wednesday, March 26, 2008

Tip: Creating a .zip file of a subdirectory tree in Windows Explorer

You can quickly and easily create a .zip file containing the files and subfolders in a particular subdirectory tree in Windows XP by right-clicking the root folder of the subdirectory tree to be compressed in Explorer, and then selecting Send To | Compressed (zipped) Folder from the context menu that appears.

Windows Explorer: Send To | Compressed Folder

Doing this causes Explorer to create a .zip file with the contents of the subdirectory tree (with the same name as the name of the tree's root folder, plus a ".zip" extension), located in the same folder as the subdirectory tree's root folder. The files in the created .zip archive retain their full path information (so that the folder structure of the subdirectory tree will be retained when the archive is later uncompressed).

This technique is handy for doing things like compressing the subdirectory tree of a small development project's source code, in order to easily send the code (in the form of the created .zip file) to another machine. The technique is also nice because it doesn't require the use of any 3rd-party tools.

Monday, March 17, 2008

Utility of the day: Dropper

Have you ever wanted to know the specific color of something shown on your computer screen? Dropper by Brian Friesen is a lightweight Windows utility that will let you do just that. It will show you the color of any pixel on your screen, regardless of which running application the pixel is located in.

One limitation of Dropper is that it is an older application ("older" in this case meaning 2006!), and doesn't have multi-monitor support; it can only show the color of pixels in the primary monitor on multi-monitor systems.

You can download Dropper from its page on Brian's website.

Tuesday, March 11, 2008

Utility of the day: Ditto

In most of today's major operating systems, the built-in clipboard has a significant limitation: it can hold only a single item a time. If you cut or copy a second item onto the clipboard, the first item is gone, with no direct way to recover it. Jeff Atwood posted about this issue recently in more depth on his excellent Coding Horror blog.

From the comments on Jeff's post, I learned about an excellent Windows utility that addresses this problem: Ditto. Ditto allows you to use a configurable system-wide hotkey (I'm currently using Ctrl+Alt+v) which brings up a "history browser" with all items that had been recently copied to the clipboard. Ditto automatically takes care of saving clipboard items, so that older items are no longer lost when a new item is copied to the clipboard.

Since installing Ditto on my machine, I've found myself using it more and more. In addition to being able to easily paste items that I know that I had on the clipboard recently, avoiding having to re-copy or retype them, Ditto enables me to in some cases plan ahead and do things more efficiently. For example, say that I have a large text document open, and I want to copy two nearby (but not adjacent) snippets of text from a location near the beginning of the document, and paste each of them to a location near the end of the document. With just basic operating system clipboard functionality, I'd need to:

  • Copy item 1;
  • Scroll to the end of the document;
  • Paste item 1;
  • Scroll back to the beginning of the document;
  • Copy item 2;
  • Scroll back to the end of the document;
  • Paste item 2.
With Ditto, I can achieve the same end result more quickly:
  • Copy item 1;
  • Copy item 2;
  • Scroll to the end of the document;
  • Paste item 2;
  • (Using Ditto) Paste item 1.
Ditto is written in C++, and is free and open-source. You can download it from the Ditto Homepage.

Thursday, March 06, 2008

Leading/Trailing space characters in filenames

Did you know? On Windows, it's legal for filenames to have leading space characters! I've developed on Windows for years, but didn't realize this until just recently. For example, at a command prompt, in a directory that contains a file named t.txt, the following works:

C:\temp> copy t.txt " t.txt"
        1 file(s) copied.
This results in a directory listing like:
 Directory of C:\TEMP\spaceTest

03/06/2008  05:29 PM    <DIR>          .
03/06/2008  05:29 PM    <DIR>          ..
03/06/2008  05:29 PM                 4  t.txt
03/06/2008  05:29 PM                 4 t.txt
               2 File(s)              8 bytes
What about Linux/Unix? I tested briefly using a couple of servers running HP-UX and RedHat Linux at the office, and found that both Linux and Unix (at least the flavors that I tested) support both leading and trailing spaces in filenames! For example, at a shell prompt, in a folder that initially contains just the file t.txt:
$ ls -Q
"t.txt"
$ cp t.txt " t.txt"
$ cp t.txt "t.txt "
$ cp t.txt " t.txt "
$ ls -Q
" t.txt"  " t.txt "  "t.txt"  "t.txt "
$

(The -Q flag on ls as used in the example above causes filenames in the listing to be displayed enclosed in doublequotes, which was useful for showing that the filenames do indeed include space characters. The -Q flag is supported on the copy of ls on the RedHat Linux server I'm testing on here, but not on the HP-UX server.)

The fact that filenames can contain leading (and, on Linux/Unix, trailing) space characters seems like a good thing for developers to be aware of. Use caution when writing code that trims leading and trailing whitespace from a string that represents a filename!

Tuesday, March 04, 2008

Workaround: Thinkpad gets into "always scroll down" state

Two or three times over the past six months or so of daily usage of my Lenovo (IBM) Thinkpad T60 laptop, I've encountered an issue where the system seems to get stuck in a "always scrolling down" state: in the active/foreground application, if the application has a vertical scroll bar, the document automatically scrolls to the bottom, even though I'm not touching the mouse wheel or otherwise doing anything that would cause the document to scroll. If I manually scroll the document up by dragging the vertical scrollbar up with the mouse, the document scrolls back down again as soon as I release the mouse button to drop the scrollbar.

The issue has always seemed to occur when I'm sitting at my desk at work and the Thinkpad is in its docking station, and I'm working with the external USB mouse. The operating system I'm running is Windows XP Pro SP2.

The workaround/solution for this issue that I've found is to just press the middle trackpoint button on the laptop once. This is the button located between the left and right mouse buttons, just below the spacebar and just above the touch pad. Thinkpad Trackpoint center button

I'm not very happy that I don't know what exactly causes my system to get into this "always scrolling down state", or why clicking the center trackpoint button gets the system out of this state, but having this workaround is a lot better than nothing!

I hope this is helpful to anyone arriving at this post from a search engine query who may be experiencing a similar issue!