Skip to content

Instantly share code, notes, and snippets.

@seancdavis
Last active January 6, 2023 08:21
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment