Question

I have multiple rtf files in a folder. I need to concatenate these into one rtf file using Ruby v1.9.3 on Windows.

This is what I have so far:

files_to_be_joined = Dir["*.rtf"]

File.open("Joined.rtf", "w") do |output_file|
  files_to_be_joined.each do |input_file|
    File.open(input_file) do |file|
      file.each { |line| output_file.puts line }
    end
  end
end

This works in a mechanical sense: It puts all of the rtf files in the folder together. When I open Joined.rtf in a text editor, I can see that it includes all of the rtf files in the folder. But when I open Joined.rtf in MS Word, I can only see the first one.

Any suggestions would be appreciated.

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top