Most podcast receiver programs keep each feed in separate subdirectories. I was using this Ruby utility to flatten out all the files into a single directory before I copy them to my mp3 player. I actually use Yapcaster now which writes all the files out to a single directory making this utility obsolete for my particular purpose.

Side Note: This article was written in 2008 so some of the references may be out-of-date.

The Ruby ftools library makes available several class methods to the File class, for copying, moving, deleting, installing, and comparing files, as well as creating a directory path.

You could also use Ruby FileUtils instead as it contains the same functionality.

#!/usr/bin/ruby -w
require 'ftools'

pathIn = 'C:/Personal/Ruby/temp-in'
pathOut = 'C:/Personal/Ruby/temp-out'

#----------------------------------------------------------------------
# Pass 0 - Get file list
#----------------------------------------------------------------------

theFileList = []; 
Dir[pathIn + '/**/*.*'].each do |fnn| 
  theFileList << fnn;
end;

#----------------------------------------------------------------------
# Pass 1 - extract name and copy file
#----------------------------------------------------------------------

theFileList.each do |f| 
    fni = f.reverse;
    ii = fni.index('/')
    if ii > 0 then
      fnn = fni[0,ii]
      fnn = fnn.reverse
    else
      fnn = f
    end
    fno = pathOut + '/' + fnn
    puts "#{f} -> #{fno}"
    File.copy(f, fno)
end;

#----------------------------------------------------------------------
# All Done....
#----------------------------------------------------------------------

puts 'press return to continue...'
gets