Skip to content

Instantly share code, notes, and snippets.

@chenkovsky
Created November 5, 2014 10:40
Show Gist options
  • Save chenkovsky/9f04f52730c177de9f2f to your computer and use it in GitHub Desktop.
Save chenkovsky/9f04f52730c177de9f2f to your computer and use it in GitHub Desktop.
ruby codes
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