I'm working on a C program to batch rename files in reverse order. To make it easy I'm hard coding the file names - using a loop - instead of using C to read the directory. My problem is getting the "Count Up" printf values into the "old_name" variable of the rename function. Same thing with the "Count Down" printf value for "new_name".


Code:
#include <stdio.h>
#define PREFIX "_MG_"
#define EXT ".JPG"

int main()

{

	int start_suffix = 7398, end_suffix = 8199, suffix = 9010;

	while (start_suffix <= end_suffix ) {

	// Count Up
	printf("%s%04d%s",PREFIX, start_suffix, EXT);
	start_suffix++;

	// Count Down
	printf("%s%04d%s\n",PREFIX, suffix, EXT);
	suffix--;

	rename("old_name", "new_name");
	}
	return 0;
}
The print output is exactly what I want for the renaming of the files. Now if I just could get those values into the rename function I think my program will be OK. Thanks.