Efficient File Name Changes: How to Automate the Process with Programming

  • Thread starter Thread starter n1person
  • Start date Start date
  • Tags Tags
    File
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
3 replies · 3K views
n1person
Messages
144
Reaction score
0
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!
 
Physics news on Phys.org
There is also the more general problem of turning (2 random letters)(number)-(2 other random letters)(another number).txt --> (number)(another number).txt
 
<io.h> or <stdio.h>

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

Such things can be located just by googling.