From: Phrogz Date: 2006-07-21T03:15:05+09:00 Subject: *.rb not running on Windows any more At work, I installed 1.8.2 from the one-click. I wrote a handy utility named "findfile.rb", and put it in my windows\system32 directory. I was happy, because I could open any cmd window and type "findfile ..." and my ruby script would kick the crap out of Windows' built-in search features. But then I installed 1.8.4 from the one-click. Now, when I type "findfile ..." in a command window, Windows rudely informs me: "'findfile' is not recognized as an internal or external command, operable program or batch file." The findfile.rb file is still in the same spot. Ruby was installed in the same spot. I've tried associating *.rb with c:\ruby\bin\ruby.exe and c:\ruby\bin\rubyw.exe, but to no avail. Who can help me in my quest to continue to kick the crap out of Windows' built-in search? (For those interested, following is my hack script. It was originally written to allow regexp filename searching, and was later expanded to allow regexp content searching, too.) require 'rubygems' require_gem 'Usage' usage = Usage.new "name_regexp [content_regexp]" class Dir def self.crawl( path, max_depth=nil, depth=0, &block ) return if max_depth && depth > max_depth begin if File.directory?( path ) files = Dir.entries( path ).select{ |f| f[0,1]!='.' } unless files.empty? files.collect!{ |file_path| Dir.crawl( path+'/'+file_path, max_depth, depth+1, &block ) }.flatten! end return files elsif File.file?( path ) yield( path, depth ) end rescue SystemCallError => the_error warn "ERROR: #{the_error}" end end end start_time = Time.new name_match = Regexp.new( usage.name_regexp, true ) content_match = usage.content_regexp && Regexp.new( ".{0,10}#{usage.content_regexp}.+", true ) matching_count = 0 Dir.crawl( '.', usage.max_depth ){ |file_path, depth| if File.split( file_path )[ 1 ] =~ name_match if content_match if IO.read( file_path ) =~ content_match puts file_path," #{$~}"," " matching_count += 1 end else puts file_path matching_count += 1 end end } end_time = Time.new puts "(Found #{matching_count} files in #{end_time-start_time} seconds)"