Chris G. wrote:
So all this is simply to ask: What is the Windows equivalent to the
Spotlight Ruby Importer.
Wow, that’s sort of sexy. Hadn’t seen that before.
(Screenshots in action: http://rubyurl.com/9sx )
The Windows Way might be to use the Find command (Windows-F) and enter
content type in “A word or phrase in the file”. Bleah.
What I do is use my little “findfile” ruby script (code below) from the
command line. It’s sort of like a grep utility that allows you to use
regexps as a filter for file names, and as a content searcher. For
example
C:\Documents and Settings\gavin.kistner\Desktop>findfile rbw?$ “def
\S+awl”
./ReArchive/Archive/dircrawl.rb
def self.crawl ( path, level=0 )
Found 1 file (out of 7510) in 2.765 seconds
C:\WINDOWS\system32>type findfile.rb
require_gem ‘usage’
usage = Usage.new “[-d %max_depth] 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 )
file_count = 0
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
file_count += 1
}
elapsed = Time.new - start_time
puts “Found #{matching_count} file#{matching_count==1?’’:‘s’} (out of
#{file_count}) in #{elapsed} seconds”