Skip to content

Instantly share code, notes, and snippets.

@gjtorikian
Last active May 27, 2018 17:43
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 gjtorikian/29fbc764d6221363bf4aadd4cf59c22e to your computer and use it in GitHub Desktop.
Save gjtorikian/29fbc764d6221363bf4aadd4cf59c22e to your computer and use it in GitHub Desktop.
Geocities extraction script
require 'pty'
def run_cmd(cmd)
begin
PTY.spawn( cmd ) do |stdout, stdin, pid|
begin
# Do stuff with the output here. Just printing to show it works
stdout.each { |line| print line }
rescue Errno::EIO
puts "Errno:EIO error, but this probably just means " +
"that the process has finished giving output"
end
end
rescue PTY::ChildExited
puts "The child process exited!"
end
end
dirs = %w(UPPERCASE)
dirs.each do |dir|
Dir.chdir(dir) do
puts dir
Dir["*.7z.001"].sort.each do |file|
basename = File.basename(file, ".*" )[0..-4]
if File.exist?(basename)# || basename < "geocities-C-z.7z"
puts "Skipping #{basename}"
next
end
puts "Working on #{file} ..."
run_cmd("7za x #{file} > /dev/null")
run_cmd("tar -zxf #{basename}")
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment