Category : Batch File Utilities - mostly for DOS
Archive   : MRUN.ZIP
Filename : RUN.C
Output of file : RUN.C contained in archive : MRUN.ZIP
Executes same program against multiple files when program only
accepts one files name
Syntax: RUN PROGRAM_NAME FILES OPTIONS */
#define TRUE 1
#define FALSE 0
#include
#include
main(int argc,char *argv[])
{
int j;
int k;
int PAUSE=FALSE;
int BATCH=FALSE;
char DriveName[60]="";
char runline[100]="";
int Drive=FALSE;
int FilesArg=0;
FILE *bat;
int start=1;
struct ffblk block;
/* printf("%d %d %s\n",argc,j,argv[j]); */
if (argc==1)
{
Help();
exit();
}
if (argv[1][0]=='/')
{
start=2;
j=1;
while (*(argv[1]+j))
{
switch (toupper(*(argv[1]+j)))
{
case '?':
Help();
break;
case 'B':
BATCH=TRUE;
break;
case ('P'):
PAUSE=TRUE;
break;
};
j++;
}
}
/* Find the files argument */
for (j=start;j
if (strchr(argv[j],'*') || strchr(argv[j],'?'))
{
FilesArg=j;
break;
}
}
/* Validity check */
if (FilesArg==0)
{
printf("Run needs files with either the * or ? wildcards");
exit();
}
else if (FilesArg==1)
{
printf("Multiple files cannot precede the program to run");
exit();
}
/* Determine if a dir/drive exists */
k=strlen(argv[FilesArg]);
while (argv[FilesArg][k]!='\\' && argv[FilesArg][k]!=':')
k--;
if (k>0)
{
strcpy(DriveName,argv[FilesArg]);
DriveName[k+1]='\0';
Drive=TRUE;
}
if ((bat=fopen("run0.bat","w"))==NULL)
{
printf("Can't open batch file for further processing");
exit();
}
if (findfirst(argv[FilesArg],&block,0))
{
printf("Invalid path or no file names with the designation %s",argv[FilesArg]);
exit();
}
do
{
strcpy(runline,"");
for (j=start;j
strcat(runline,argv[j]);
strcat(runline," ");
}
if (Drive)
strcat(runline,DriveName);
strcat(runline,block.ff_name);
for (j=FilesArg+1;j
strcat(runline," ");
strcat(runline,argv[j]);
}
fprintf(bat,"%s\n",runline);
if (PAUSE)
fprintf(bat,"PAUSE\n");
}
while (!findnext(&block));
fclose(bat);
if (!BATCH)
system("run0");
else
printf("Type RUN0 to execute the batch file\n");
}
int Help()
{
printf("\nRUN will execute a program against multiple files\n");
printf("when the program only runs with one filename\n\n");
printf("RUN/options command_line\n\n");
printf("? Help\n");
printf("P Pause between executions\n");
printf("B Batch file RUN0.BAT created but not executed\n");
printf("\nExample: RUN TYPE A*.* will type each file starting with A\n");
printf(" RUN/P TYPE A*.* will pause after wach file\n");
printf(" RUN/B TYPE A*.* will create the run.bat file but not execute it\n");
printf(" RUN/BP TYPE A*.* will create the batch file with pauses\n");
exit();
}
Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!
This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.
But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/