_finddata_t fd;
long handle;
int result=1;
int i=0;
int count=0;
handle=_findfirst(READ,&fd);
if (handle == -1) return;
while (result != -1) {
count++;
printf("Open file name:%s\n",fd.name);
while(fd.name[i]==NULL){//파일 이름의 길이를 알기위해...
i++;
}
if(i>500){
printf("fd.name size:%d\n",i);
printf("변경하려는 파일 %s의 이름이 너무 길어요\n",fd.name);
exit(1);
}
sprintf(fname,"f:\\브라운 아이드 소울 2집 [the wind! the sea! the rain]\\%s",fd.name);//읽을 려고 하는 파일
mkdir("c:\\lrc");
sprintf(fcopy,"c:\\lrc\\%s",fd.name);
fp=fopen(fname,"r");
out=fopen(fcopy,"w+");
if(fp==NULL){
printf("오류: File open error(read file)\n");
exit(1);
}
if(out==NULL){
printf("오류: File open error(write file)\n");
exit(1);
}
memset(str,0,sizeof(str));
for(;;){
if((fgets(str,sizeof(str),fp))==NULL){
printf("\n완료\n\n");
break;
}
for(i=0;i<sizeof(str);i++){//변환 작업 시작
if(str[i]=='.'){
for(;i<sizeof(str);i++){
str[i]=str[i+3];
}
}
}
printf("내용:%s",str);
if(str==NULL){
printf("\n\n오류: str is null\n\n");
exit(1);
}
fputs(str,out);
}
fclose(fp);
result=_findnext(handle,&fd);
}
_findclose(handle);
printf("%d개의 파일을 변환 하였습니다.",count);
}