Skip to content

Instantly share code, notes, and snippets.

@cdale77
Created July 25, 2014 22:19
Show Gist options
  • Save cdale77/d8502ef11373862f8eaa to your computer and use it in GitHub Desktop.
Save cdale77/d8502ef11373862f8eaa to your computer and use it in GitHub Desktop.
Recursively copy and rename files with Ruby
#!/usr/bin/env ruby
require 'fileutils'
files = Dir["*/*.PDF"].collect{|f| File.expand_path(f)}
files.each_with_index do |file, index|
puts "copying file #{index}"
FileUtils.cp file, "pdf/#{index}.pdf"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment