2

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
Shilpi Agrawal
  • 595
  • 3
  • 11
  • 26

1 Answers1

2

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) }
Maxim
  • 9,701
  • 5
  • 60
  • 108