From: Mohit Sindhwani Date: 2009-10-16T02:53:34+09:00 Subject: Re: output file name based on original file name Collin Moore wrote: > I have a simple txt parsing script that I'd like to have the output be > named after the original text file. > > original = original.txt > output = original_output.txt > > I'm just doing a simple file.open, and couldn't find anything. > > File.open('output.txt', 'w') do |f2| > File.readlines("original.txt").each do |line| > > Thanks in advance for any help. > This is the simplest... output_file = "#{input_file}_output.txt" On the other hand, you can look at the FileUtils to see how to get the base name or the name without extension, etc... so that you can make it more productive. I'm just suggesting the simplest. Cheers, Mohit. 10/16/2009 | 1:53 AM.