G
G
Groofy2015-03-16 14:24:22
File managers
Groofy, 2015-03-16 14:24:22

How to structure files and folders?

Given

OS - Windows 7
Folder with many folders and files

Required
Map all files and folders

Example
Папка_1
//Папка_1_1
////Файл_1_1_1.jpg
////Файл_1_1_2.png
////Файл_1_1_3.html
//Папка_1_2
Папка_2
Папка_3

I consider both scripts and programs

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vladimir Martyanov, 2015-03-16
@vilgeforce

FindFirstFile + FindNextFile

L
Lex Fradski, 2015-03-16
@SerMelipharo

In cmd.exe use tree %ПУТЬ% /F >вывод.txt
more details: tree /?;)
Cool, isn't it? I myself, however, until you asked, did not remember this feature

V
Viktor Milov, 2019-12-22
@Tanyki

#include
#include
#include
#include
#include
#include
#include
#include
#include
static QJsonArray fList;
static int extraSize = 0;
using namespace std;
void folderHandler(QString folderPath) {
for (QFileInfo f : QDir(folderPath).entryInfoList()) {
if (!f.isDir()) {
QJsonObject fileInfo {
{"fileName", f.fileName()},
{"size ", f.size()},
{"path", f.filePath()}
};
fList.push_back(fileInfo);
} else if (f.fileName() != "." && f.fileName() !
folderHandler(f.absoluteFilePath());
}
}
}
void fileHandler() {
QJsonArray copyFileList = fList;
for (int i = 0; i < fList.size(); i++) {
QJsonArray duplicateList;
QJsonObject buf = fList[i].toObject();
for (int k = 0; k < copyFileList.size(); k++) {
if (copyFileList[k].toObject().value("fileName") == buf.value("fileName") &&
copyFileList[k] .toObject().value("size") == buf.value("size")) {
duplicateList.push_back(copyFileList[k].toObject());
copyFileList.removeAt(k);
k--;
if (duplicateList.size() > 1) {
extraSize += duplicateList[0].toObject().value("size").toInt() * (duplicateList.size()-1);
for (QJsonValueRef d : duplicateList) {
qDebug() << d.toObject().value("path").toString();
}
}
}
}
int main()
{
QString path = "C:\\Text";
qDebug() << "root dir" << QDir(path).absolutePath();
//folderHandler(path);
fileHandler();
qDebug() << "extra size" << extraSize << "b";
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question