Skip to content

Instantly share code, notes, and snippets.

@twhite96
Forked from seancdavis/script.rb
Created September 14, 2022 22:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save twhite96/13f33329cd55e7713f89f8cec617eceb to your computer and use it in GitHub Desktop.
Save twhite96/13f33329cd55e7713f89f8cec617eceb 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