Skip to content

Instantly share code, notes, and snippets.

@cristianoliveira
Last active June 6, 2016 03:48
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 cristianoliveira/45e7a8c78d2662f9e828083adb2bab38 to your computer and use it in GitHub Desktop.
Save cristianoliveira/45e7a8c78d2662f9e828083adb2bab38 to your computer and use it in GitHub Desktop.
Music folder sorter
require 'fileutils'
musics = Dir["*.mp3"]
musics.each do |music|
band_name = music.split("-").first
dir_destiny = "#{band_name}/"
Dir.mkdir(band_name) unless File.exists? band_name
FileUtils.mv music, dir_destiny
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment