Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Outputting file sizes of each item in a directory (error)

Reply
Thread Tools

Outputting file sizes of each item in a directory (error)

 
 
Feng Tien
Guest
Posts: n/a
 
      11-13-2007
code:


Dir.foreach("bad") do |f|
puts "#{f}: #{File.size f}"
end
============
Each filename in the directory "bad" is displayed along with the file
size.

I know the file.size works because I tried it with an static name and
displayed fine.

the error I got

============
lib/dir_test.rb:6:in `size': No such file or directory - IMG_0964.jpg
(Errno::ENOENT)
from lib/dir_test.rb:6
from lib/dir_test.rb:5:in `foreach'
from lib/dir_test.rb:5
============
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Win 7 changing font sizes without icon sizes? why? Computer Support 0 03-21-2010 11:32 AM
Re: Win 7 changing font sizes without icon sizes? why? Computer Support 0 03-21-2010 11:31 AM
How to access file last modified dates on each file in a directory RAMohrmann@adelphia.net Python 3 10-30-2006 06:40 AM
The File Sizes of Pictures on my CDs Increased to Unreadable Sizes Marful Computer Support 11 03-08-2006 07:13 PM
why writing list to file puts each item from list on seperate line? homepricemaps@gmail.com Python 5 12-31-2005 05:21 AM



Advertisments