Last active
January 6, 2023 08:21
Move files up one directory in Ruby
This file contains hidden or 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