Path: utzoo!utgpu!cs.utexas.edu!usc!julius.cs.uiuc.edu!psuvax1!eds1!wa3wbu!gdx!jay From: jay@gdx.UUCP (Jay A. Snyder) Newsgroups: alt.sources Subject: Neat utility to convert uppercase filenames Message-ID: <76@gdx.UUCP> Date: 7 Dec 90 18:39:51 GMT Organization: GDX-BBS, Mechanicsburg, PA Lines: 77 Did you ever do mget from simtel20 or ymodem batch downloads from an MSDOS BBS, and get a lot of uppercase files in your directory? Well this is a utility that will take all specified files and convert them to lower case. One exception is that trailing .Z's will be left uppercase eg. % ls FILE.ZIP FOO.BAR TESTARC.TAR % fdncase * FILE.ZIP ==> file.zip FOO.BAR.Z ==> foo.bar TESTARC.TAR.Z ==> testarc.tar % ----- snip snip ----- #include #include usage() { fprintf(stderr,"fdncase: File DowNcase\n"); fprintf(stderr,"usage: fdncase file1 file2 ...\n"); exit(0); } char *strtolcpy(d,s) char *s,*d; { char *r; r=d; while (*d++=tolower(*s++)); return(r); } #ifdef SYSV rename(old,new) char *old,*new; { int error; if (!(error=link(old,new))) { unlink(old); return(0); } else return error; } #endif main(argc,argv) int argc; int *argv[]; { int i; char tmpstr[80]; if (argc==1) usage(); for (i=1;i %s\n",argv[i],tmpstr); else fprintf(stderr,"error renaming %s\n",argv[i]); } else { fprintf(stderr,"%s already lower case\n",argv[i]); } } }