Skip to content

Instantly share code, notes, and snippets.

@milesmatthias
Created October 6, 2014 00:02
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 milesmatthias/30acbad4b1218a369c65 to your computer and use it in GitHub Desktop.
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
#!/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