Last active
January 4, 2016 22:14
-
-
Save boxmein/c34c840bdf96f9fb10be to your computer and use it in GitHub Desktop.
Ruby script to naively consolidate a bunch of HexChat logs. You can figure out date order etc yourself. Mwahahahah
This file contains hidden or 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
#!/usr/bin/env ruby | |
# Ruby script to consolidate all my log folders | |
require 'thread' | |
PREFIX="/home/#{`whoami`}/.config/hexchat/logs/" | |
FOLDERS=["freenode", "freenode over znc", "poke_freenode"] | |
file_q = Queue.new | |
threads = [] | |
puts "\n---\nScanning the folders for logs..." | |
FOLDERS.each do |folder| | |
log_dir = File.join(PREFIX, folder, "*.log") | |
puts "Looking for logs in #{log_dir}" | |
Dir.glob(log_dir) do |file| | |
puts "Queuing file for copying: #{file}" | |
file_q << file | |
end | |
end | |
4.times do | |
threads << Thread.new do | |
until file_q.empty? | |
infile_name = file_q.pop | |
outfile_name = File.join("./freenode/", File.basename(infile_name)) | |
puts "Copying file #{infile_name} to #{outfile_name}" | |
File.open(infile_name, "r") do |infile| | |
File.open(outfile_name, "a") do |outfile| | |
while line = infile.gets | |
outfile.puts line | |
end | |
end | |
end | |
end | |
end | |
end | |
threads.map &:join | |
puts "Finished consolidating logs, hopefully." | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment