Skip to content

Instantly share code, notes, and snippets.

@ahirschberg
Last active September 7, 2016 00:59
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 ahirschberg/521da3140f10bac527a85ac3a46eef2d to your computer and use it in GitHub Desktop.
Save ahirschberg/521da3140f10bac527a85ac3a46eef2d to your computer and use it in GitHub Desktop.
laziness
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