Created
November 5, 2014 10:40
-
-
Save chenkovsky/9f04f52730c177de9f2f to your computer and use it in GitHub Desktop.
ruby codes
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
def delete_matching_regexp(dir, regex) | |
Dir.entries(dir).each do |name| | |
path = File.join(dir, name) | |
if name =~ regex | |
ftype = File.directory?(path) ? Dir : File | |
begin | |
ftype.delete(path) | |
rescue SystemCallError => e | |
$stderr.puts e.message | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment