How to apply a name filter to file name and directory name?
-
I want to apply a name filter to file name and directory name. And I want to list files only.
QDirIterator directory_iterator("C:\\test\\abc", QStringList() << "*test*.txt", QDir::Files, QDirIterator::Subdirectories);
For example, files exist like as follows.
C:\test\abc\test1.txt
C:\test\abc\1test.txt
C:\test\abc\test\z.txt
C:\test\abc\z.txtand I want list files below.
C:\test\abc\test1.txt
C:\test\abc\1test.txt
C:\test\abc\test\z.txtBut currently I only get a list like below.
C:\test\abc\test1.txt
C:\test\abc\1test.txtIs there any option relate to it? Thanks for reading!
-
You filter for "test.txt" as filename so what you get is correct. If you also want 'test' then adjust your filter to "test"
-
Thank you for your answer. I want to apply a filter to directory name too.
I would like to list the files that satisfy the conditions below.- extension is ".txt"
- file name or directory name contain a keyword "test"
But currently it works like below.
- extension is ".txt"
- file name contain a keyword "test"
-
You have to filter it later by your own.
-
@Christian-Ehrlicher
I got it. Thanks. 👍😁