seancdavis
7/14/2017 - 8:43 PM

Move files up one directory in Ruby

Move files up one directory in Ruby

require 'fileutils'

path = File.expand_path('../', __FILE__)
Dir.glob("#{path}/**/*.*").each do |file|
  new_path = "#{path}/#{file.split('/')[-1]}"
  FileUtils.mv(file, new_path)
end