performance - efficient directory traversal for archivable folders -
performance - efficient directory traversal for archivable folders -
there file server have been asked clean (pentium 4! 512 meg of ram!!). gets files added directory construction consists of few provinces, within each province directory town directories, within each town directory are 'newspaper' directories, within each paper directory 'story' directories, , within each story directory are files named string consisting of topic , date. each file looks this: water poisons yak 2013-04-11.doc, malaria peak 2012-01-05, etc. have filter collection story directories inactive (no contributions within 3 years). collection filtered 1 time month. 1000 new files added every month. collection has 80,000 files.
my solution run through each story directory , check name of each file this:
sub loopthroughfiles(storyfolder) dim myobj object, mysource object, file variant file = dir(storyfolder) while (file <> "") if (instr(file, "2013") or instr(file, "2014") > 0) msgbox "recent file found. move on next directory" recentdir = true exit sub end if file = dir wend end sub
this checks if year 2013 or 2014 in filename. if years not found,then run through story folder 1 time again checking year 2012 , month in similar way. if month more recent current 1 not found, whole story directory moved. in visual basic, accomplished changing pathname of every file in particular story directory. means run through story folder 1 time again (a 3rd time), time assigning different pathname each file.
my question has right design of algorithm efficient. know if folder can archived, filenames of contents have inspected. if loop through whole collection in origin , load array (to create subsequent searches faster ) need ton of memory. on other hand, looping through each directory 3 times seems wasteful. sense question should have been solved ask.
although have utilize visual basic, principles behind question fundamental , applicable language. not hesitate reply in computer language (in english language though).
performance vba directory-structure
Comments
Post a Comment