Created
June 26, 2019 17:03
-
-
Save PatrickTulskie/a4bdcdecc499047488e6b6b7e79c904b to your computer and use it in GitHub Desktop.
Randomly delete files from a directory
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
#!/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