慕少3274410
47
#include
#include
intmain(intargv, char*argc)
{
longhandle;
inti=0, j=0;
struct_finddata_tfileinfo;
charfilePT[256]={'\0'};
charfileType[20]={'a','\0'};
charfilePath[256]={'\0'};
charnewName[256]={'\0'};
charoldName[256]={'\0'};
printf("Input the rename filePath:\n");
scanf("%s", filePath);
fflush(stdin);
printf("Input the rename fileType:\n");
scanf("%s", fileType);
fflush(stdin);
sprintf(filePT, "%s\\*%s",filePath, fileType);
handle = _findfirst(filePT,& fileinfo);
if(-1 == handle)
{
printf("_findfirst() error\n");
getchar();
return(-1);
}
i=1000;
do{
sprintf(oldName, "%s\\%s", filePath, fileinfo.name);//全部路径
sprintf(newName, "%s\\%d%s", filePath, i++, fileType);
j=rename(oldName, newName);
if(j != 0)
{
printf("rename() error\n");
break;
}
}while( !_findnext(handle,& fileinfo) );
_findclose(handle);
printf("Program End\n");
getchar();
return(0);
}