PDA

View Full Version : Changing File Names in C


n1person
Dec6-10, 03:35 PM
Hello all,

I have another little computer problem to deal with. I have a folder full of files (over a thousand) with the basic form KJ(number)-j(another number).txt, and I want to change the style to (number)(another number).txt. Is there any simple way to do this as the only way I can think of is a program which opens the file, opens a new file, copies the contents from the open file to the new file, and closes the two files, which seems timely and rather inefficient.

Thanks for your help!

n1person
Dec6-10, 03:40 PM
There is also the more general problem of turning (2 random letters)(number)-(2 other random letters)(another number).txt --> (number)(another number).txt

Borek
Dec6-10, 04:05 PM
<io.h> or <stdio.h>

int rename(
const char *oldname,
const char *newname
);

Such things can be located just by googling.

schip666!
Dec6-10, 06:01 PM
There's a cute little Widows file manager add-on called "multiren" that might do what you want. Here's the first link I got when googling: http://www.freewareweb.com/cgi-bin/archive.cgi?ID=173