Home / code

lower case

Writer: Christophe Wolfs
Published: 27 March 2008

This program is created for, and tested on Windows 2000 (DOS-mode). But should work on other systems as well.

This is a small program I created to convert files names to lower characters.
Windows has the anoying habit to convert filenames to uppercase characters.
This no problem for windows systems but if you have to transfer it to another system (like linux) it might break applications (like web-applications).
So this program convert all the file-names in a directory to lowercase. Simple.

#include <stdio.h>
#include <windows.h>

HANDLE hDir;

char * ConverToLower(char * string)
{
  int i=0;

  while(string[i])
  {
    if(string[i] >= 'A' && string[i] <= 'Z')
    {
      string[i]=string[i]+32;
    }
    i++;
  }
  return string;
}

int main()
{
  fprintf(stderr, "Start program \n");
  WIN32_FIND_DATA file_data;

  hDir=FindFirstFile("*", &file_data);

  while(FindNextFile(hDir, &file_data))
  {
    //for renaming the files
    rename(file_data.cFileName, ConverToLower(file_data.cFileName));
  }

  FindClose(hDir);
  fprintf(stderr, "END program");
  return 0;
}

 

TOP