-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathto_lower_case.cpp
More file actions
84 lines (72 loc) · 2.21 KB
/
to_lower_case.cpp
File metadata and controls
84 lines (72 loc) · 2.21 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*
CREATED BY: Jakub Kozupa
DATE: 31.08.2019
FEEL FREE TO USE
*/
#include "stdafx.h"
#include <iostream>
#include <string>
#include <fstream>
#include <algorithm>
#include <vector>
#include <ctime>
bool fileExists(const std::string& filePath)
{
std::ifstream f(filePath.c_str());
return f.good();
}
int main()
{
std::vector<std::string> file = { "AreAambienceData.txt", "AreaData.txt", "AreaProperty.txt" };
std::vector<std::string> directories = { "00000", "00100", "00200", "00300", "00400", "00500", "00600", "00700", "00800", "00900" };
bool endForDir = false;
int amountOfChanges = 0;
int breakAmount = 0;
double difference;
clock_t start, end;
start = clock();
for (int i = 0; i < directories.size(); i++)
{
//std::cout << "Petla glowna nr " + std::to_string(i) << std::endl;
// FOR EVERY DIR (EX.: 000001, 000002, 000003 ... 002000, 002001, 002002 etc..)
for (int j = 0; j < directories.size(); j++)
{
if (!endForDir) {
//std::cout << "Petla wewnetrzna" << std::endl;
std::string dir = directories[i] + std::to_string(j);
for (int k = 0; k < file.size(); k++)
{
//std::cout << "Petla zmieniajaca nazwe" << std::endl;
std::string path = dir + "\\" + file[k];
std::string oryginalPath = path;
std::transform(path.begin(), path.end(), path.begin(), ::tolower);
if (fileExists(oryginalPath))
{
if (rename(oryginalPath.c_str(), path.c_str()) == 0)
std::cout << "Zmieniono: " + path << std::endl;
amountOfChanges += 1;
breakAmount = 0;
}
else
{
//std::wcout << "BREAK!!" << std::endl;
endForDir = true;
breakAmount += 1;
break;
}
}
}
else endForDir = false;
if (breakAmount >= 3) break;
}
if (breakAmount >= 3) break;
}
end = clock();
difference = (end-start)/(double)CLOCKS_PER_SEC;
std::cout << std::endl << "---------------------------------" << std::endl;
std::cout << "Lacznie zmieniono nazwe: " + std::to_string(amountOfChanges) + " plikow!" << std::endl;
std::cout << "Czas wykonywania programu: " + std::to_string(difference) + " sekund." << std::endl;
std::cout << "Program zakonczyl prace, wcisnij [ENTER] aby wyjsc." << std::endl;
std::cin.get();
return 0;
}