Skip to content

Instantly share code, notes, and snippets.

@itszero
Created June 26, 2009 06:51
Show Gist options
  • Save itszero/136342 to your computer and use it in GitHub Desktop.
Save itszero/136342 to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby
dir = ARGV[0]
Dir.glob("#{dir}/*.zip").each do |f|
basename = File.basename(f, ".zip")
system "mkdir #{dir}/#{basename}"
system "unzip #{f} -d #{dir}/#{basename}"
arr = Dir.glob("#{dir}/#{basename}/*")
if arr.size == 1 && File.directory?(arr[0])
system "mv #{arr[0]}/* #{dir}/#{basename}/"
system "rm -rfv #{arr[0]}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment