/ Published in: Ruby
Rake task - Copies files from one directory to another in a batch of 50 files, giving 15 seconds break between each batch.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
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