main page | gallery | rationale | contact

a utility to enforce filesystem aesthetics

Written:Fall 2001
Last Touched:Fall 2001


I wrote this utility around the time that I started using Windows 2000 on my computer and found an interesting 'feature' of archival programs. My favorite archival tool, WinRAR, has the tendency to store files and with filenames in all uppercase. Normally, I wouldn't care, but since Microsoft changed the default Explorer setting in Windows 2000 to show all uppercase filenames instead of hiding them like in previous versions, I began to grow uncomfortable with the aesthetics of my ALL_CAPS project directories.

Of course, I could have change my Explorer settings, but now that I knew that the files were being stored in nasty uppercase, I felt compelled to fix it, so I wrote a little utility to go through a directory and change all of the filenames to a much more aesthetically pleasing lowercase format.

What Was Difficult?

Figuring out how to get directory information out of Windows with only the merely adequate MSDN documentation as a guide. As with most aspects of Windows programming, it took a bit of experimentation to get it to work properly.

For a breath of fresh air, here's a bit of nasty C string-processing code:

toLower.c (excerpt)

#define isUpper(a)	(a >= 'A' && a <= 'Z') ? 1:0
#define isLower(a)	(a >= 'a' && a <= 'z') ? 1:0

// Function: toLower
// Description:	changes all of the characters in 
//	a string to lowercase
void toLower(char *sz)
	while(*sz != '\0')
			*sz += 32;

It could be worse, but the advantage of this form is that it is human-readable. Quick C review: C functions are pass by value, thus I can increment and tweak the sz pointer without messing up the original string pointer. The magic number 32 is the difference between lower and upper case letters in the ASCII character set.

What you need to compile & run this

For Windows, I'd recommend Microsoft Visual C++ 6.0 or greater, since that's exactly the tool I used to develop this project. This project only uses standard Windows API calls, so it should compile straight out of the zip.

For Linux, I'd recommend looking at the man page for the POSIX-compliant opendir() function and its cousins, readdir(), and closedir(). Implementation of this program using POSIX-compliant directory traversal calls is left as an exercise for the curious. Shouldn't take too long to do! (11.4 K) (3.78 K)

Last updated: 2003.02.27 by