Created
July 5, 2016 18:42
-
-
Save kirushik/f35531f9e0d866df1e61beff08419520 to your computer and use it in GitHub Desktop.
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 | |
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