Re: [Dev-C++] reading and comparing filenames
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Alfred P. R. <al...@ya...> - 2005-02-25 22:58:44
|
Try the _findfirst/_findnext/_findclose set of functions. I believe they allow regular expression searching. I'm using them with both wildcard searches '*', '*.*', and with searches for a specific name. It would be something like:
entrydir = getcwd(NULL, MAX_FOLDER_TEXT_SIZE);
chdir(startpoint_for_search);
if ((findhandle = _findfirst(search_string, &finddata)) == EOF) {
// One wasn't found.
...
}
{ // Process a found one!
...
} while( (result = _findnext(findhandle, &finddata)) == 0 )
_findclose(findhandle);
chdir(entrydir);
free(entrydir);
You must close the find handle, always, and free the entrydir variable if you use the above form. I use the above in recursive folder searching.
Guillermo Gutierrez <ggu...@ma...> wrote:
I have a bit of a dilemma, I have an app that copies files from one folder to another.
Now I need to copy different files from a second folder but I dont want to get all of them.
As newer versions of these files are created, the previous versions are renamed to "filename.****.bpl" as opposed to "filename.bpl".
the "****" is a four digit number representing the file time from the timestamp. I want to copy only the newer files (filename.bpl) and not the previous ones (filename.****.bpl).
What would be the best way to:
a) get a list of the filenames.
b) filter down to a list of the newer filenames (w/o the ".****")
c) and finally copy only the ones on the filtered list.
Guillermo Gutierrez
Market Scan Information Systems
Software Q.A. Supervisor
(818) 575-2000 x2427
ggu...@ma...
Alfred P. Reaud
|