I have thousands of files to go through with a directory structure like this:
YYYY_MM_DD
XXX
XXX
XXX
Target
.hdr files
XXX
XXX
more .hdr files but do not want to process
YYYY_MM_DD
XXX
XXX
XXX
Target
.hdr files
XXX
XXX
more .hdr files but do not want to process
I have three months of data to go through and I need to get to the Target folder, and the Target folder only. They contain the files that we need to look at and some of the other folders have .hdr files as well that we do not need to look at.
At first, I used a QDirIterator
such as:
QDirIterator it(inputDir, QStringList() << "*.hdr", QDir::Files, QDirIterator::Subdirectories);
However upon running my program I realized that this was going to grab the other .hdr
files as well and I do not need to process those files. This is the code that I wrote that would find all of the .hdr
files:
QDirIterator it(inputDir, QStringList() << "*.hdr", QDir::Files, QDirIterator::Subdirectories);
std::vector<std::string> files;
while(it.hasNext())
{
files.push_back(it.next().toStdString());
}
return files;
How can I traverse the directories but only take the files within the Target folder?