I want to get the file names of all files that have a specific extension in a given folder (and recursively, its subfolders). That is, the file name (and extension), not th
a C++17 code
#include #include #include namespace fs = std::filesystem; int main() { std::string path("/your/dir/"); std::string ext(".sample"); for (auto &p : fs::recursive_directory_iterator(path)) { if (p.path().extension() == ext) std::cout << p.path().stem().string() << '\n'; } return 0; }