A
Ahmet Kilic
I need some help about keywords searching in directory and files.
I have a directory
dirs--a
|--b
|--c
and files
a-->a1.txt
|-->a2.txt
|-->a3.txt
I can lsit all files and directories like this,
require 'find'
dirs = ['C:\\Users\\test\\dirs']
keywords = ["keyword1","keyword2"]
for dir in dirs
Find.find(dir) do |path|
if FileTest.directory?(path)
if keywords.include?(File.basename(path))
# make something here... and output the finding data
else
Find.prune # skip the files
next
end
else
puts path
end
end
end
how can I do it and how can I print output the results in a text or csv
file?
Or need a plugin like Ferret?
please help me.
I have a directory
dirs--a
|--b
|--c
and files
a-->a1.txt
|-->a2.txt
|-->a3.txt
I can lsit all files and directories like this,
require 'find'
dirs = ['C:\\Users\\test\\dirs']
keywords = ["keyword1","keyword2"]
for dir in dirs
Find.find(dir) do |path|
if FileTest.directory?(path)
if keywords.include?(File.basename(path))
# make something here... and output the finding data
else
Find.prune # skip the files
next
end
else
puts path
end
end
end
how can I do it and how can I print output the results in a text or csv
file?
Or need a plugin like Ferret?
please help me.