c++ get all folders in directory filesystem code example
Example 1: c++ get files in directory
#include <string>
#include <iostream>
#include <filesystem>
namespace fs = std::filesystem;
int main() {
std::string path = "/path/to/directory";
for (const auto & entry : fs::directory_iterator(path))
std::cout << entry.path() << std::endl;
}
Example 2: number all files in a folder
ls -v | cat -n | while read n f; do mv -n "$f" "$n.ext"; done