Return to Snippet

Revision: 9560
at November 12, 2008 04:52 by cnicolaou


Initial Code
desc "Lists all files in a directory"
task :list do
  Dir.chdir(C_DIR)
  fs = Dir.glob('**/*.JPG')
  count, similar_files = 0
  initial = 50
  fs.each do |f|
    if File.file? f
      puts "#{count += 1} -> Copying #{f} to #{REMOTE_DIR}"
      unless File.exist?("#{REMOTE_DIR}#{f.to_s}")
        File.copy(old_file, new_file, verbose => true)
      else
        similar_files += 1
      end
      if count == initial
        initial += 50
        sleep(15)
      end
    end
  end
  puts "Number of Similar files: #{similar_files}"
end

Initial URL


Initial Description
Rake task - Copies files from one directory to another in a batch of 50 files, giving 15 seconds break between each batch.

Initial Title
File listing and copying between directories

Initial Tags
file, ruby, copy

Initial Language
Ruby