On 04.04.2010 18:25, Hawksury Gear wrote: >> Your error is most likely caused by the fact that Dir#entries returns >> file names only, i.e. without a path. You are trying to open different >> files than you think (most likely in the current directory). >> >> Kind regards >> robert > > Many Thanks for replying robert, It makes sense what you have said. > I think it would be a lot easier if I just explain my end goal. I think > my approach is probably wrong. This is what I want to achieve, > > "Processing every single file that is in a particular directory" > > My current approach is , > > 1. Getting all files from a Directory using ab > =Dir.open("K:/test/").entries You should close the Dir object properly. You can either use the block form of Dir.open or use the approach I have used below. > 2. Iterating over each file that is in the directory by doing; > ab.each do |f| > 3. Applying "File.open" method (with required permission) to every > single 'file' by doing, > ab.each do |f| > File.Open(f,"w+") do |readfile| > > 4. Finally manipulating/processing each file line by line. > > But what you said makes sense it looks like Dir.Open().entries doesn't > return a "file object" that can be manipulated it rather returns a > string (file name only). > Do you have any idea how this can be addressed? There are different ways. You can create proper file names with the tools you have already: dir = "K:/test" Dir.entries(dir).each do |file| path = File.join dir, file if File.file? path File.open path do |io| io.each_line do |line| ... end end end end Or you can use the elegant Pathname library: require 'pathname' dir = Pathname "K:/test" dir.entries.each do |file| if file.file? file.each_line do |line| ... end end end > Sorry to be a pain... new to Ruby! No need to worry. We all start out as beginners at some point in time. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/