I have a script that combs through a particular folder and finds all of the documents that have been modified today:
Dir.glob("/path/to/folder/*/*.txt") do |file|
f = File.open(file.strip)
lines = f.readlines
mod = f.mtime
modtime = f.mtime.strftime("%I:%M%p")
text = lines.join
wordcount = text.split.length
project = File.basename(file).gsub(/.txt/, ' ').strip
if mod > (Time.now - 86400)
found_completed = true
entry = "#{modtime} - #{project} - #{wordcount}"
end
if found_completed == false
puts "not today"
end
if found_completed == true
puts "worked on #{entry}"
end
end
That all works fine. However, I also went to write that multi-line output to a file. When I add this to the end of the script (before the final 'end') it comes up blank:
open('/path/to/newfile.txt', 'w') { |f|
f.puts ("#{entry}" + "/n/n") }
Any help would be appreciated.