Created
October 6, 2014 00:02
-
-
Save milesmatthias/30acbad4b1218a369c65 to your computer and use it in GitHub Desktop.
short ruby script used to move movies in a file structure created by itunes into a flat structure
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
#!/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 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment