Skip to content

Instantly share code, notes, and snippets.

@seancdavis
Last active January 6, 2023 08:21
Show Gist options
  • Save seancdavis/a00baf1c59d60219ac87d87d71a26d46 to your computer and use it in GitHub Desktop.
Save seancdavis/a00baf1c59d60219ac87d87d71a26d46 to your computer and use it in GitHub Desktop.
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