Hi, I am trying to create a simple program to rename a bunch of files

    #include <stdio.h>

    int main(){

        int count;

        for(count = 1; count <= 95; count++){

            if(count >= 10){
            system("rename \"C:\\wamp\\www\\anime\\kenshin\\Rurouni Kenshin - %d.mkv\" \"%d.mkv\"", count, count);
            }

            /* For the episodes that have 0 before the number e.g 01..09 */
            system("rename \"C:\\wamp\\www\\anime\\kenshin\\Rurouni Kenshin - %d%d.mkv\" \"%d.mkv\"", 0, count, count); 
        }

    return 0;
}

I keep on receiving the "The system cannot find the file specified." message when I run it but I know it is the right path. I have tried using the rename() function but it tells me that I have "too many actual parameters".. Can someone help a newbie out?

You have to format the string with sprintf() before passing it to system() or rename() functions -- those functions don't work like printf().

/* For the episodes that have 0 before the number e.g 01..09 */

That's not necessary. Just use "%0.2d" and the number will have 0 before the first digit if there is only 1 digit.
char buf[50];
sprintf(buf,"\"C:\wamp\www\anime\kenshin\Rurouni Kenshin - %0d.mkv\" \"%d.mkv\"", count, count);

The above should have been "d.mkv"

I hate not having an edit button!!!

"d.mkv"

try it again

% 0 2 d.mkv

Got it working! Thanks for your help!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.