Facing problem in copying of files of type *.txt and *.xls from one folder to other folder?

Hi All,

I am facing problems in copying of files from one location to other.

For example, there are folders starting from 1 to 6.
First time i wanted to copy *.txt and *.xls file present in folder 1 to
the PWD and do some other stuff and then followed by all the other
folders. for this initially i have copied all the folders path into a
read.txt files and the trying to iterate folder by folder. its fine in
this approach but if the txt file name changes then i can’t able to do
that. The logic i am using is below:

require ‘csv’
require ‘fileutils’

dest_folder = File.join(Dir.pwd)

CSV.foreach(“read.txt”) do |row| # read.txt contains the path
where xls and txt files are available.
data_to = “#{row}”
concat = File.join(data_to)

Source1 = File.join(concat, “file1.txt”)
Source2 = File.join(concat, “file2.xls”)

FileUtils.cp_r(Source1, dest_folder)
FileUtils.cp_r(Source2, dest_folder)
sleep 3
puts “I am at end”
end

currently i am sending file names all the time. I wanted to get rid of
this. I wanted to implement in such a way that what ever the file name
ends with *.txt i should be able to copy?
Please let me know what improvement i can do to the current ruby script
such that i can copy file one by one and do my job…

Thanks in advance