#include <windows.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
int iFolderCount;
char name[20];
std::string sMainPath = "NE100-Rotterdam OPS-IRT\\";
CreateDirectory(sMainPath.c_str(), NULL);
cout << "How many you need a subfolders:\n";
cin >> iFolderCount;
cout << "Give a Name a subfolders:\n";
cin >> name;
for (int i=0; i<=iFolderCount; ++i)
{
cout << "\n Creating ";
cout << i;
cout << ": Folder\n";
std::ostringstream ss;
ss << i;
std::ostringstream named;
named << name;
int nr1,nr2,nr3,nr4,nr5;
nr1 = 0;
nr2 = 0;
nr3 = 0;
nr4 = 0;
nr5 = 0;
if(nr1==9)
{
nr1=0;
if(nr2=9)
{
nr2=0;
if(nr3==9)
{
nr3=0;
if(nr4==9)
{
nr4=0;
if(nr5==9)
{
nr5++;
}
else
{
cout<<"ERROR! Too many Folders!";
}}
else
{
nr4++;
}}
else
{
nr3++;
}}
else
{
nr2++;
}}
else
{
nr1++;
}
std::ostringstream n1,n2,n3,n4,n5;
n1 << nr1;
n2 << nr2;
n3 << nr3;
n4 << nr4;
n5 << nr5;
std::string sFolderName = named.str()+"-"+n2.str()+n5.str()+n4.str()+n3.str()+n1.str()+ "00-" +n1.str()+ "99\\" ;
CreateDirectory((sMainPath+sFolderName).c_str(), NULL);
for (int l=0; l<=99; ++l)
{
std::ostringstream ll;
ll << l;
if(l<10)
{
CreateDirectory((sMainPath+sFolderName+named.str()+n2.str()+n5.str()+n4.str()+n3.str()+"0"+ss.str()).c_str(), NULL);
std::string subFolderName =named.str()+n2.str()+n5.str()+n4.str()+n3.str()+"0"+ss.str()+"\\";
CreateDirectory((sMainPath+sFolderName).c_str(), NULL);
CreateDirectory((sMainPath+sFolderName+subFolderName+"Correspondence IN\\").c_str(), NULL);
CreateDirectory((sMainPath+sFolderName+subFolderName+"Correspondence OUT\\").c_str(), NULL);
CreateDirectory((sMainPath+sFolderName+subFolderName+"Fieldreport\\").c_str(), NULL);
CreateDirectory((sMainPath+sFolderName+subFolderName+"Internal\\").c_str(), NULL);
CreateDirectory((sMainPath+sFolderName+subFolderName+"Raport\\").c_str(), NULL);
}
else
{
CreateDirectory((sMainPath+sFolderName+named.str()+n2.str()+n5.str()+n4.str()+n3.str()+n1.str()+ll.str()).c_str(), NULL);
std::string subFolderName =named.str()+n2.str()+n5.str()+n4.str()+n3.str()+n1.str()+ll.str()+"\\";
CreateDirectory((sMainPath+sFolderName).c_str(), NULL);
CreateDirectory((sMainPath+sFolderName+subFolderName+"Correspondence IN\\").c_str(), NULL);
CreateDirectory((sMainPath+sFolderName+subFolderName+"Correspondence OUT\\").c_str(), NULL);
CreateDirectory((sMainPath+sFolderName+subFolderName+"Fieldreport\\").c_str(), NULL);
CreateDirectory((sMainPath+sFolderName+subFolderName+"Internal\\").c_str(), NULL);
CreateDirectory((sMainPath+sFolderName+subFolderName+"Raport\\").c_str(), NULL);
}
}
}
cout << "\n\n I Made ";
cout << iFolderCount;
cout << " Folders \n\n";
system("PAUSE");
return EXIT_SUCCESS;
}
Mógłby ktoś sprawdzić co nie tak jest bo już siedze od 1godziny i błędu nie mogę znaleŹć.
Gdy wpisze liczbę folderów 11. Tworzy jedynie pod foldery w pierwszym