Finding the next file name in a group of folders

S

Scott McNair

We have several IP cameras, and an application that constantly streams jpg
images off of these cameras to a share. These images are stored with the
convention:

S:\Snapshots\CameraName\YYYY\MO\DD\HH\MI\CameraName.YYYYMODDHHMISSMIL.jpg

(YYYY = year, MO = month, [...], MIL = millisecond)

I'm writing another application that will play these streamed jpegs to an
end-user. The problem I'm running into seems simple on the surgace, but is
for some reason eluding me.

I'd like to write a function that, when passed a date element, will find
the file that corresponds most closely to that date... so if I pass in
9/18/2009 11:13:00, it will find the first file that occurs after that
date, regardless of the subfolder it's in.

I've tried a handful of ways to retrieve it, but they're either overly
convoluted or ridiculously time-consuming. There are several GB of images,
so I can't pull a large list of files into an array and them limit them
down based on the date, and recursing through the folder hierarchy is
overly convoluted.

Does anybody know of a robust, quick solution that would do what I need?

Regards,
Scott
 
M

Miro

I am curious as to what your final solution will be, but a simple solution
might be:

The very first time, go through all the folders and add a "link" to an sql
database.

Have the "search" run off that database...
at the same time, have a file watcher on the folder, and when a new file is
added, add it to the db.

If you find a hit in the db, thats when you check if it actaully exists.
That way if a file is deleted, you can handle it internally.

The filewatcher will grab any new ones created.

Just a thought.

Miro
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top