Hi there.

I'm writing a simple system to order certain data.
Now this is the deal: I have a bunch of files with the following filename structures (stored as strings):

i represents a random number. Now I want to scan whether the file has that structure, and if it has that structure, it should rename it to FILENAME.EXT.

So basically, I want to program to check whether a certain structure is present in the filename, and if so, it should rename the string.

Any ideas how on how to solve this problem?

Thanks in advance!

Eddy Wally

Something like this?

char filename[] = "00001234_FILENAME.EXT";
char newfilename[100];
if ( sscanf( filename, "0000%*d_%s", newfilename) == 1 ) {
  // format seems to be as expected

That's amazing! Thank you very much!

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.