Skip to content

Instantly share code, notes, and snippets.

@kirushik
Created July 5, 2016 18:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kirushik/f35531f9e0d866df1e61beff08419520 to your computer and use it in GitHub Desktop.
Save kirushik/f35531f9e0d866df1e61beff08419520 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'find'
ACCESS_DENIED = ["$Recycle.Bin", "Documents and Settings", "Program Files", "Program Files (x86)", "ProgramData", ".", ".."]
def search(name, dirname = ".")
Find.find(dirname).find do |path|
! ACCESS_DENIED.include?(File.basename(path)) &&
! File.directory?(path) &&
File.basename(path) == name
end
end
print "Enter file name for search: "
result = search(gets.strip)
puts "File #{@name} exists in folder #{File.dirname result}" if result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment