954,492 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Mp3 Bulk Name Changer - With Errors

This code is done using C. Whole point of it is to remove the name just before the first hyphen. Its blindly written so I haven't improved it and it has extra variables and no reuse of variables to save space. If anyone can just locate the error why the printed output has the 1st letter missing then let me know. I will add a system(temp); line to make the renaming possible but for now I have just left a printf to check how the temp value is stored. Help me out here, thanks!

#include<stdio.h>
#include<stdlib.h>
int main()
    {
        int i,j,k,x,y,flag=1;
        FILE *fp;
        char ch=0,location[300],renameto[255],temp[255]="ren ";
        system("dir /b > filx.txt");
        printf("Directory listing saved, beginning renaming operations\n");
        system("ping -n 5 localhost>nul");
        fp=fopen("filx.txt","r");
        while(1)
           {
               for(i=0;ch!='\n';i++)
                   {
                       ch=fgetc(fp);
                       location[i]=ch;
                   }
               location[i-1]=32;
               location[i]='\0';
               for(j=0,k=0;location[j]!='\0';j++,k++)
                    {
                       while(flag)
                         {
                             while(location[j-1]!='-')
                                    j++;
                            flag=0;
                         }
                       renameto[k]=location[j];
                    }
                flag=1;
                renameto[k]='\0';
                for(x=0;location[x]!='\0';x++)
                  temp[x+4]=location[x];
                for(x,y=0;renameto[y]!='\0';x++,y++)
                  temp[x]=renameto[y];
                  temp[x+1]='\0';
               printf("Str: %s\n\n",temp);i=0;
               ch=fgetc(fp);
              if(ch==EOF)
                 break;
           }
           fclose(fp);
           return 0;
    }
timetraveller92
Light Poster
Banned
38 posts since Jul 2011
Reputation Points: 2
Solved Threads: 4
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: