Last active
September 7, 2016 00:59
-
-
Save ahirschberg/521da3140f10bac527a85ac3a46eef2d to your computer and use it in GitHub Desktop.
laziness
This file contains 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
require 'pathname' | |
require 'shellwords' | |
dirs = Pathname.new('.').children.select { |c| c.directory? } | |
pwd = Pathname.pwd | |
begin | |
Dir.mkdir pwd + 'output' | |
rescue Errno::EEXIST | |
puts "directory existed already. great..." | |
end | |
dirs.each do |dir| | |
begin | |
Dir.chdir(dir + 'Submission attachment(s)') | |
output_filename = Shellwords.shellescape(dir.to_s.gsub(/\s/, '_')) | |
output_path = pwd + 'output' + output_filename | |
puts "Outputting to #{output_path}" | |
`java -cp #{pwd} 'hw0Output' > #{output_path}.txt` | |
rescue | |
puts "**Malformed directory #{dir}**" | |
end | |
Dir.chdir(pwd) | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment