rendered paste body#include <fstream>#include <iostream>#include <stdio.h>#include <string.h>#include <windows.h>using namespace std;int oldNamesCount;int newNamesCount;int main (){char newFileName[256];char oldFileName[256];// char suffix[21]; WIN32_FIND_DATA FindFileData; HANDLE hFind = INVALID_HANDLE_VALUE; char DirSpec[5]= "."; // directory specification cout<<"\n"; strncat(DirSpec, "\\*", 3); hFind = FindFirstFile(DirSpec, &FindFileData); int fileOutputCount = 0; ofstream a_file ( "oldnames.txt" ); if (a_file.is_open() ) { while(FindNextFile(hFind, &FindFileData) != 0) { ++fileOutputCount; if (fileOutputCount > 1 ) { if (!( strcmp( FindFileData.cFileName , "renamer.exe" ) == 0)) if (!( strcmp( FindFileData.cFileName , "oldnames.txt" ) == 0)) if (!( strcmp( FindFileData.cFileName , "index.txt" ) == 0)) a_file<<FindFileData.cFileName<<"\n"; } } }FindClose(hFind);a_file.close();ifstream check( "index.txt" ); if (check.is_open() ) {FILE* fp_fileNames = fopen( "index.txt" , "r" );FILE* fp_oldNames = fopen ( "oldnames.txt" , "r" );FILE* fp_fileToName;// char* extention;while(!feof(fp_fileNames)){ fgets (oldFileName , 255 , fp_oldNames); char *o = strchr(oldFileName, '\n'); if (o) *o = '\0'; fgets (newFileName , 255 , fp_fileNames); char *p = strchr(newFileName, '\n'); if (p) *p = '\0'; strcat (newFileName , ".ab1" ); fp_fileToName = fopen(oldFileName, "r"); /* open file just to check if it exists */ if(fp_fileToName != NULL) /* check if file exists */ { fclose(fp_fileToName); rename(oldFileName, newFileName); cout<<"Renaming "<< oldFileName <<" to "<< newFileName <<". \n"; } else { cout<< "Error, "<< oldFileName <<" does not exist. \n"; } } }else { cout<< "Error, index.txt does not exist. \n";}cin.get();}// main