Skip to content

Instantly share code, notes, and snippets.

@KrzaQ
Last active August 29, 2015 14:19
Show Gist options
  • Save KrzaQ/e7191d8778a2ad493162 to your computer and use it in GitHub Desktop.
Save KrzaQ/e7191d8778a2ad493162 to your computer and use it in GitHub Desktop.
SearchDir = ARGV[1] || 'D:/Backup/mfc'
LogFormat = /^(\d{10}).+\.bak$/
MinimumFileAge = 3 * 60 * 60
# Today = Time.new.strftime('%Y%m%d%H%M')
Name = 'MFC'
OutDir = 'D:/Backup/mfc/'
FileLists = Dir["#{SearchDir}/*.bak"].sort[0...-10].select{ |fileName|
# p fileName
base = File.basename fileName
LogFormat =~ base && Time.new - File.ctime(fileName) > MinimumFileAge
}.map{ |fileName|
base = File.basename fileName
[ "#{base}.7z", File.absolute_path(fileName) ]
}
# p FileLists
FileLists.each do |zipName, fileName|
command = '7z a -t7z %{dir}/%{zipName} %{fileName} -r -mx9 -mmt=10 on' % {
:zipName => zipName,
:fileName => fileName,
:dir => SearchDir
}
p command
File.delete fileName if system(command)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment