Skip to content

Instantly share code, notes, and snippets.

@PatrickTulskie
Created June 26, 2019 17:03
Show Gist options
  • Save PatrickTulskie/a4bdcdecc499047488e6b6b7e79c904b to your computer and use it in GitHub Desktop.
Save PatrickTulskie/a4bdcdecc499047488e6b6b7e79c904b to your computer and use it in GitHub Desktop.
Randomly delete files from a directory
#!/usr/bin/env ruby
puts "Gimme a directory" and exit if ARGV.first.nil?
directory = Dir.new(File.expand_path(ARGV.first))
directory.each do |file|
next if %w(. ..).include?(file)
if rand(2) == 1
puts "Deleting #{file}"
File.delete(file)
else
puts "Sparing #{file}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment