Rename File In Dev C++

Hi all. I have thousands of files that need to be renamed. What I have is a folder full of files (named sequentially) and then a .txt file with the desired names of each file (also in sequential order). What I need is a program that opens the .txt file, reads a line and then goes to the folder and renames the file, traverses the .txt file by one line, reads said line and then goes to folder and renames the next file.. so on and so forth. I've taken c++ in college several years ago but haven't coded since then. I'm trying to access each file using directory functions (which I've never had experience with). Is this the correct approach? So far, this is what I have come up with but I am clueless on how to get any further. Thanks for any and all help!
#include <iostream>
#include <fstream>
#include <string>
#include <dirent.h>
using namespace std;
int main()
{
DIR * dir = opendir('J:Folder_Name')
ifstream inFile ('desiredName.txt');
string line,
oldFile,
newFile;
inFile.open();
if (!dir)
cout << 'Error opening directory.' << endl;
else
{
struct dirent *entry;
while (entry = readdir(dir))
{
oldFile = entry->d_name;
if ( !inFile.is_open() )
cout << 'Failed to open input file.' << endl;
else
{
getline(inFile, line);
cout << line << endl;
newFile = line;
}
if (newFile.size() 0;
cout << 'File read error.' << endl;
//here is where I get stuck
how am I supposed to go about renaming the current 'entry' and then get both the directory and the inFile to traverse to the next line??

Rename A File In C

Rename File In Dev C++

Rename File In Dev C Download

Steps to recreate. Create new file in project rename 'untiled' file to 'foobar.h' save 'foobar.h' rename 'foobar.h' file 'FooBar.h'. This will delete file.