Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.47 KB | None | 0 0
  1. require 'find'
  2.  
  3. def handle_dir(dir)
  4.   Find.find(dir) do |entry|
  5.     if File.file?(entry)
  6.       handle_file(entry)
  7.     end
  8.   end
  9. end
  10.  
  11. def handle_file(file)
  12.   if `file "#{file}"` =~ /SQLite/
  13.     `echo "VACUUM;" | sqlite3 "#{file}"`
  14.     `echo "ANALYZE;" | sqlite3 "#{file}"`  
  15.   end
  16. end
  17.  
  18. location = ARGV.shift
  19.  
  20. if location != nil
  21.   if File.file?(location)
  22.     handle_file(location)
  23.   else
  24.     handle_dir(location)
  25.   end
  26. else
  27.   handle_dir(Dir.getwd())
  28. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement