#include
#include
#include
#include
void deleteAdvertise(const char *filename)
{
char content[1024];
char *t_content;
char newcontent[1024];
int index = 0;
const char *advertising="[捌零音乐论坛]";
char *tempchar = NULL;
FILE *stream = fopen(filename, "r");
char newfilename[1024];
strcpy(newfilename, filename);
strcat(newfilename, ".cue");
FILE *newstream = fopen(newfilename, "w");
if (stream == NULL)
{
fprintf(stderr, "fopen error");
return;
}
while(fgets(content, 100, stream) != NULL)
{
t_content = content;
if ((tempchar=strstr(t_content, advertising)) != NULL)
{
index = 0;
while(t_content != tempchar)
{
newcontent[index++]=t_content[0];
t_content++;
}
t_content = t_content + strlen(advertising);
while(t_content[0]!='\0')
{
newcontent[index++] = t_content[0];
t_content++;
}
newcontent[index] = '\0';
}
else
{
strcpy(newcontent, t_content);
}
fputs(newcontent, newstream);
}
fclose(stream);
fclose(newstream);
}
int main()
{
DIR *p_dir = opendir("D:/梁静茹");
DIR *pp_dir;
char *parentdir;
char tempdir[1024];
chdir("D:/梁静茹");
struct dirent *p_ent;
while((p_ent=readdir(p_dir)) != NULL)
{
if (strcmp(p_ent->d_name,".") != 0 && strcmp(p_ent->d_name, "..") != 0)
{
parentdir = p_ent->d_name;
strcpy(tempdir, parentdir);
strcat(tempdir, "/");
pp_dir = opendir(p_ent->d_name);
while((p_ent=readdir(pp_dir)) != NULL)
{
if (strstr(p_ent->d_name, ".cue") != NULL)
{
strcat(tempdir, p_ent->d_name);
printf("%s\n", tempdir);
deleteAdvertise(tempdir);
}
}
}
}
return 0;
}
阅读(1167) | 评论(0) | 转发(0) |