Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
how to calculate file number in a folder
Li Chen
10/20/2006 7:07:00 PM
Hi folks,
I write a script to find out all the file names and the number of files
in a folder(no other children folder) as following:
Dir.open('C:/Ruby/self').each{
|file|
puts file if file=~/(\w+)|(\d+)/ # remove file .
and ..
}
but I am not sure how to calculate the number of file in folder.
Any help will be appreciated.
Li
--
Posted via
http://www.ruby-...
.
1 Answer
snacktime
10/20/2006 8:24:00 PM
0
files = Dir.entries('/tmp')
p files.class
files.delete_if {|x| ['.','..'].include?(x) } # Get rid of . and ..
entries on unix
p files
p files.size
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
how to calculate file number in a folder
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password