-
Notifications
You must be signed in to change notification settings - Fork 0
/
renamer.cpp
44 lines (33 loc) · 935 Bytes
/
renamer.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <bits/stdc++.h>
#include <fstream>
#include <string>
#include <cstdio>
#include <vector>
#include <sstream>
using namespace std;
string changeString (int a)
{
// declaring output string stream
ostringstream str1;
// Sending a number as a stream into output
// string
str1 << a;
// the str() coverts number into string
string geek = str1.str();
// Displaying the string
return geek;
}
int main ()
{
ifstream file("names.txt");
if (file.fail()) cout << "Failed to open input file" << endl;
vector<string> names;
string line;
while(file >> line) names.push_back(line);
for (size_t i=1; i <= names.size(); ++i)
{
int success = rename(string(changeString(i)).c_str(), names[i-1].c_str());
}
// I used this to change folder names, to change specific file names append the extension to the string in the end
return 0;
}