-
-
Save KrzaQ/d267078ec144dccaa98c to your computer and use it in GitHub Desktop.
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
SearchDir = ARGV[1] || 'D:/mfc/bin' | |
LogFormat = /^(\d{4})-(\d\d)-(\d\d)-(.+)\.log$/ | |
Name = 'MFC' | |
OutDir = 'D:/Logs/MFC/' | |
# do not touch below | |
Today = Time.new.strftime('%Y-%m-%d') | |
FileLists = Dir["#{SearchDir}/*.log"].select{ |fileName| | |
base = File.basename fileName | |
base =~ LogFormat && base[0...10] != Today | |
}.group_by{ |fileName| | |
File.basename(fileName)[0...10] | |
}.map{ |date, files| | |
[date, files.map{|fileName| File.absolute_path fileName }] | |
}.to_h | |
# p FileLists | |
FileLists.each do |date, files| | |
command = '7z a -t7z %{out}/%{date}_%{name}.7z %{files} -r -mx9 -mmt on' % { | |
:out => OutDir, | |
:date => date, | |
:files => files.join(' '), | |
:name => Name | |
} | |
p command | |
# `#{command}` | |
files.each{ |fileName| File.delete fileName } if Kernel.system(command) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment