home *** CD-ROM | disk | FTP | other *** search
-
- /*
- * Capit - by Robert Lang ⌐ EdgeWare
- *
- * A Simple program to Capitalize all files/directories in a directory,
- * if this source is modified, the modified version must be sent to me :
- *
- * Robert Lang
- * EdgeWare
- * P.O. Box 127
- * CARDIFF NSW 2285
- * AUSTRALIA
- *
- * No part of this source may be used in commercial software without
- * written permission.
- *
- * Revision :
- *
- * 10th July 1991 - V1.0, Robert Lang.
- *
- */
-
- #define VERSION "V1.0"
- #define TODAY "10th July 1991"
-
- #include <stdio.h>
- #include <libraries/dos.h>
- #include <exec/types.h>
- #include <ctype.h>
-
- /* main program */
-
- main(int argc, char *argv[])
- {
- /* get a read lock on the current directory */
- struct FileLock *dir_lock;
- struct FileInfoBlock info_block;
- register BOOL stat;
- char oldname[108],newname[108],path[80] = "",midname[108];
-
- if (argc > 2)
- {
- printf("\nCapit "VERSION" by Robert Lang "TODAY".\n\nUsage :\t"
- "%s directory\n\nAnd all files/directories in that"
- " directory will be capitalised.\n\n",argv[0]);
- return;
- }
-
- if (argc == 2)
- {
- if ((argv[1][strlen(argv[1])-1] == ':') || (argv[1][strlen(argv[1])-1] == '/'))
- strcpy(path,argv[1]);
- else sprintf(path,"%s/",argv[1]);
- }
-
- if (dir_lock = (struct FileLock *)Lock(path,ACCESS_READ))
- {
- if (stat = Examine(dir_lock,&info_block))
- {
- stat = ExNext(dir_lock,&info_block);
- while (stat)
- {
- printf("%s",info_block.fib_FileName);
-
- if (strlen(info_block.fib_FileName) < 8)
- printf("\t\t\t");
- else printf("\t\t");
-
- if (islower(info_block.fib_FileName[0]))
- {
- strcpy(midname,info_block.fib_FileName);
- midname[0] = toupper(midname[0]);
- printf("-> %s",midname);
-
- sprintf(newname,"%s%s",path,midname);
- sprintf(oldname,"%s%s",path,info_block.fib_FileName);
-
- if (!Rename(oldname,newname))
- printf(" (FAILED)\n");
- else putchar('\n');
- }
- else printf("-> %s (unchanged)\n",info_block.fib_FileName);
-
- stat = ExNext(dir_lock,&info_block);
- }
- } else printf("Examine to directory failed.\n");
-
- UnLock(dir_lock);
- }
- else printf("Lock to directory failed.\n");
- }
-