Concatenate multiple RTF files using Ruby
-
18-10-2022 - |
Frage
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.
Keine korrekte Lösung
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow