Here are all things I have tried:
files = FileList.new("c:/temp/**/*") do |file|
file.exclude("c:/temp/logs/")
end
files = FileList.new("c:/temp/**/*") do |file|
file.exclude("c:/temp/logs")
end
files = FileList.new("c:/temp/**/*") do |file|
file.exclude("c:/temp/logs/*.*")
end
files = FileList.new("c:/temp/**/*") do |file|
file.exclude("c:/temp/logs/**/*")
end
files = FileList.new("c:/temp/**/*") do |file|
file.exclude("c:/temp/**/logs/")
end
rake version is 0.9.2.2 and Ruby version is 193. all doesn't work. How should I exclude a directory in a filelist?
I'm assuming you're trying to get a listing of all files under c:/tmp
except for anything in (and including) the c:/tmp/logs
folder:
files = FileList.new("c:/temp/**/*").exclude(/c:\/temp\/logs/)
[Edit] See the documentation for FileList#exclude
for more details. For example, to exclude multiple directories you can either add multiple string/regex arguments, modify the regular expression to match all directory patterns to be excluded, or do something similar in a block.
x1 = /c:\/temp\/logs/ # The entire "c:/temp/logs" folder.
x2 = /\.zip$/i # Any file whose name ends with ".zip".
FileList.new("c:/temp/**/*").exclude(x1, x2)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With