Created
October 6, 2014 00:02
-
-
Save milesmatthias/30acbad4b1218a369c65 to your computer and use it in GitHub Desktop.
Revisions
-
milesmatthias created this gist
Oct 6, 2014 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,27 @@ #!/usr/bin/env ruby # for each directory in the current directory: # # 1. move its contents up one directory (out of its current directory) # 2. remove the (now empty) directory # # ( note: skips hidden files and . and .. ) require 'pry' require 'fileutils' Dir.foreach(".") do |entry| next if entry.start_with?('.') if File.directory?(entry) puts "moving contents of #{ entry } up." FileUtils.mv Dir.glob(entry + "/*"), "." FileUtils.rm_r entry end end exit