Reputation: 615
I have some line of code which retrieves all the files from one folder. But its also fetching hidden files. Can someone help me in modifying that regular expression so, that it won't retrieve hidden files?
Find.find(actual_root) do |path|
file_paths << path if path =~ /.*\./
end
Upvotes: 2
Views: 901
Reputation: 9981
This line return all files and directories (exclude hidden) in actual_root
:
Dir[File.join(actual_root, '*')]
Use this if you want to take files only:
Dir[File.join(actual_root, '*')].select { |f| File.file?(f) }
Upvotes: 2