Last active
January 6, 2023 08:21
-
-
Save seancdavis/a00baf1c59d60219ac87d87d71a26d46 to your computer and use it in GitHub Desktop.
Move files up one directory in Ruby
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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