From: Brad Winborg Date: 2009-03-02T06:45:50+09:00 Subject: Re: Error when running script Tim Hunter wrote: > Brad Winborg wrote: >> error = 0 >> end >> Not a directory - D:\My Documents\Replicon\log_file_20090221_041817.txt\ >> D:/My Documents/Replicon/ErrorCount.rb:6:in `initialize' >> Press ENTER to close the window... >> >> Directory Path >> D:\My Documents\Replicon >> I was going to add an attachment to show that the directory really exits >> and that the file is in that directory, but it was to large. >> >> If anyone has any ideas as to why it is not working I be very grateful, >> as I am new to ruby code in general. > > Look at the error message. You're asking Dir.new to open the directory > "D:\My Documents\Replicon\log_file_20090221_041817.txt". > I think the directory name is actually "D:\My Documents\Replicon" and > "log_file_20090221_041817.txt" is a file within that directory. Thank you that did help, but I still have a problem. my_path = "C:\\Ruby\\Text\\" warning = 0 error = 0 d = Dir.new(my_path) d.each do |fl| unless fl == '.' or fl == '..' then puts my_path + fl File.open(my_path + fl, "r").each do |line| if line =~ /error/ then error += 1 elsif line =~ /warning/ then warning += 1 end end end end puts warning.to_s puts error.to_s The problem that I have now is that it apparently sees the file but does not read it. Below is the response that is returned. C:\Ruby\Text\log_file_20090221_041817.txt 0 0 Press ENTER to close the window... -- Posted via http://www.ruby-forum.com/.