Skip to content

Instantly share code, notes, and snippets.

@alpicola
Created April 27, 2015 09:24
Show Gist options
  • Save alpicola/b69117ff954f5e4e82e5 to your computer and use it in GitHub Desktop.
Save alpicola/b69117ff954f5e4e82e5 to your computer and use it in GitHub Desktop.
require 'fileutils'
Dir.glob('*_assignsubmission_file_*').each do |filename|
if m = /(.+)_\d+_assignsubmission_file_(.+)/.match(filename)
_, username, orig_filename = *m
FileUtils.mkdir_p(username) # if it exists, do nothing
FileUtils.mv(filename, username + '/' + orig_filename)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment