Filenames -- converting

William R. Pearson wrp at biochsn.acc.Virginia.EDU
Fri Jun 9 07:43:03 AEST 1989


In article <25879 at beta.lanl.gov> srb at beta.UUCP ( Steve Berger ) writes:
>
> I have a directory with all the filenames in Uppercase letters.
> I'd like to move them all to lowercase.
>
> Is there an easy way to do that?  I figure there must be a way using
> sed  or something, but I haven't figured it out yet, and I don't want to
> go thru and  use  mv to move each file name, that will take me forever.
>
> Any ideas will be appreciated.
>
> Steve Berger
>
> srb at lanl.gov


	Here is a program called tolower, that takes an argument and
returns it in lowercase.  Compile it and use the csh script:

	foreach file (*)
	mv $file  `tolower $file`
	end

======== tolower.c ==========

/*	tolower.c

	converts argument to lowercase on stdout
*/

#include <stdio.h>

main(argc,argv)
	int argc; char **argv;
 {
	if (argc > 1) {lowers(argv[1]); printf("%s",argv[1]); exit(0);}
	else exit(1);
	}

lowers(str)
	char *str;
{
	char tolower();
	for (; *str; str++) *str = tolower(*str);
	}

char tolower(chr)
	char chr;
{
	if (chr>='A'&& chr<='Z') return chr-'A'+'a';
	else return chr;
	}



More information about the Comp.unix.xenix mailing list