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
Get list of files and process each file and loop through them and store back in different folder
void getFilesList(string filePath,string extension, vector & returnFileName)
{
WIN32_FIND_DATA fileInfo;
HANDLE hFind;
string fullPath = filePath + extension;
hFind = FindFirstFile(fullPath.c_str(), &fileInfo);
if (hFind != INVALID_HANDLE_VALUE){
returnFileName.push_back(filePath+fileInfo.cFileName);
while (FindNextFile(hFind, &fileInfo) != 0){
returnFileName.push_back(filePath+fileInfo.cFileName);
}
}
}
USE: you can use like this load all the files from folder and loop through one by one
String optfileName ="";
String inputFolderPath ="";
String extension = "*.jpg*";
getFilesList(inputFolderPath,extension,filesPaths);
vector::const_iterator it = filesPaths.begin();
while( it != filesPaths.end())
{
frame = imread(*it);//read file names
//doyourwork here ( frame );
sprintf(buf, "%s/Out/%d.jpg", optfileName.c_str(),it->c_str());
imwrite(buf,frame);
it++;
}