Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save harssh/3d70c2bcc944e6423d4a790c70316719 to your computer and use it in GitHub Desktop.
Save harssh/3d70c2bcc944e6423d4a790c70316719 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