how to get files count in a directory using ruby

前端 未结 8 1242
北荒
北荒 2021-02-02 08:00

using ruby how to get number of files in a given Directory,the file count should include count from recursive directories.

Eg: folder1(2 files) -----> folder2(4 files)

8条回答
  •  半阙折子戏
    2021-02-02 08:39

    You could also go super bare bones and do a system command:

    count = `ls -1 #{dir} | wc -l`.to_i 
    

提交回复
热议问题