Get n number of Files from directory

  • Thread starter Thread starter bhu
  • Start date Start date
B

bhu

Hi
any idea how to get a set of files from a Directory,
if a Directory contains 100 files i want to access 10 file at a time move it
to a different directory , grab the next 10 do the same,
Also is there a way to get the First Set of File by the Date and time Stamp
FIFO
thanks
bhu
 
Also is there a way to get the First Set of File by the Date and time Stamp

Read the file information (file name and date/time) for all files in
the directory into a list. Sort by file time. Process in batches of
ten. It doesn't have to be more complicated than that. If you have
further questions on how to implement one of those steps, feel free to
follow up with a more detailed question.


Mattias
 
This way i already have it, but
i was expecting in a single function where we could say get 10 file,
thanks for the info.
 
Blu,

I am curious what is in your idea the advantage of that? Will you tell us
that?

Cor

bhu said:
This way i already have it, but
i was expecting in a single function where we could say get 10 file,
thanks for the info.
 
when i saw that we can get the file list by pattern *.xml , i was expecting
some thing simlar, which will also take the number of files as parameter and
possibly the order by Date.
Basically what i want to do is Process A will poll the directory for Files,
let us say 100 Files are there in the system, it will take the 10 Files and
give it to 10 Threads for the work to be done with the file and move the
files to some other Directory once Finished. Process A will poll after say 1
min to get the next set of files but it should fetch only 10 - (Finished
thread say this is 6)
so we need to fetch 4 Files and give it to 4 more threads, and the process
continues.( only 10 thread should be running a a time).

These are the issues Process A could pick the Same File that one of the
thread is using (this can be avoided by changing the file name by the
thread).
I hope i have explained what i am trying to do.
thanks
bhu

Cor Ligthert said:
Blu,

I am curious what is in your idea the advantage of that? Will you tell us
that?

Cor
 
Bhu,

Using threads in file processing can only lead to one thing: Rumbling of
your disk, and much more time needed for the process to finish.

This is typical a kind of process that you should not do with
multithreading.

You can poll 10 websites and than retrieve the data using multithreading,
mostly will that give as your own internet is wide enough benefit, but with
one disk (and you are talking about folders so it is one disk) it is contra
productive.

Cor
 
Back
Top