Solved file search with regexp
-
I'm looking for a way to find all files in a directory with a particular extension. For example, all .txt files within the download folder.
This seems straightforward, and I thought I could do it with
QStandardPaths::locateAll(QStandardPaths::DownloadLocation, "*.txt")
but that doesn't work.However, if I do
QStandardPaths::locateAll(QStandardPaths::DownloadLocation, "somefile.txt")
then it will return a QStringList with "somefile.txt" in it. So I think I'm close. I figured I might be able to use QRegularExpression here, but it's not clear to me how I would do that. Any suggestions? -
@kgregory said in file search with regexp:
QStandardPaths::locateAll
This is not what you need.
QDir dir("YOUR SEARCH PATH"); qDebug() << dir.entryList(QStringList() << "*.txt", QDir::Files);