PHP count total files in directory AND subdirectory function

后端 未结 6 605
小蘑菇
小蘑菇 2021-01-18 22:36

I need to get a total count of JPG files within a specified directory, including ALL it\'s subdirectories. No sub-sub directories.

Structure looks like this :

<
6条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-18 23:21

    if anyone is looking to count total number of files and directories.

    Show/count total dir and sub dir count

    find . -type d -print | wc -l
    

    Show/count total number of files in main and sub dir

    find . -type f -print | wc -l
    

    Show/count only files from current dir (no sub dir)

    find . -maxdepth 1 -type f -print | wc -l
    

    Show/count total directories and files in current dir (no sub dir)

    ls -1 | wc -l
    

提交回复
热议问题