search file in a directory

L

Li Chen

Hi folks,

Which built-in method is used to search a file in a directory and all
its children directory?

Thanks,

Li
 
E

EB

Li said:
Hi folks,

Which built-in method is used to search a file in a directory and all
its children directory?

Yup, I was looking for something similar, a simple way
to get the functionality of the unix "find" command.

I was motivated by the slow search facility under XP. Not
sure if ruby might be faster, but it made me curious how
I would specify a file to be found in a directory tree.

As a newbie I am still not quite familiar with all of the
facilities or libraries, maybe it's obvious :)

eb
 
L

Li Chen

EB said:
As a newbie I am still not quite familiar with all of the
facilities or libraries, maybe it's obvious :)

eb

Me, too. I need to spend some time to read the documentation and figure
out how to write the script.

Li
 
R

Robert Klemme

Li said:
Me, too. I need to spend some time to read the documentation and figure
out how to write the script.

Didn't you see my last reply? Do we have a gateway problem again?

robert
 
L

Li Chen

EB said:
Yup, I was looking for something similar, a simple way
to get the functionality of the unix "find" command.

I was motivated by the slow search facility under XP. Not
sure if ruby might be faster, but it made me curious how
I would specify a file to be found in a directory tree.

As a newbie I am still not quite familiar with all of the
facilities or libraries, maybe it's obvious :)

eb


Hi EB,

I think Robert kindly provies a pretty neat script which is what I want.
I am not sure if you also need a similar one like this, which searches a
directory and all children directory for the file specified.

Li

###
require 'find'

path='I:/Common/xxx/Notebooks/Flow/OT1/OTI-4'

file_number = 0

Find.find(path) do |f|

puts f if File.file?(f) && f=~/\.\d+$/
# print out the file with format xxx.001 xxx.002...
file__number+=1

end

puts file_number
 
J

James Edward Gray II

Do we have a gateway problem again?

We took some pretty drastic measures when we addressed the last
Gateway issue and haven't seen a thing since. I think we have it
pretty locked down now.

James Edward Gray II
 

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

Members online

No members online now.

Forum statistics

Threads
474,215
Messages
2,571,113
Members
47,716
Latest member
MiloManley

Latest Threads

Top