File count problems

Source: Internet
Author: User
Tags glob
The specified path is known for the file count problem. the folder under this path is the number of OK records. However, the size of each folder is limited to 100 files, and the naming rules of the folder are, and so on. How can I calculate the total number of OK files in this path?


Reply to discussion (solution)

Traverse folders (scandir) to get the number of files in the folder

$ A = glob ('specify the path/{0, 1, 2, 3, 4, 5, 6, 8, 9} */*. * ', GLOB_BRACE); echo count ($ );

$ A = glob ('specify the path/{0, 1, 2, 3, 4, 5, 6, 8, 9} */*. * ', GLOB_BRACE); echo count ($ );



The result is incorrect:

TS404> MEC91-172B1> 2825 0 --- 0
TS404> MEC91-172B1> 2827 0 --- 0
TS404> MEC91-172B1> 2828 0 --- 0
TS404> MEC91-172B1> 2901 0 --- 0
TS404> MEC91-172B1> 2903 0 --- 0
TS404> MEC91-172B1> 2904 0 --- 0
TS404> MEC91-172B1> 2906 0 --- 0
TS404> MEC91-172B1> 2907 0 --- 0
TS404> MEC91-172B1> 2909 0 --- 0
TS404> MEC91-172B1> 2910 0 --- 1
TS404> MEC91-172B1> 2914 0 --- 0
TS404> MEC91-172B1> 2915 0 --- 2
TS404> MEC91-172B1> 2917 0 --- 0
TS404> MEC91-172B1> 2921 0 --- 0
TS404> MEC91-172B1> 2X19 0 --- 0
TS404> MEC91-172B1> 2X23 0 --- 0
TS404> MEC91-172B1> 2X26 0 --- 0
TS404> MEC91-172B1> 2X29 0 --- 0
TS404> MEC91-172B1> 2X30 0 --- 0
TS404> MEC91-172B1> 2Y02 0 --- 1

--- The preceding values are all 0.

$ A = glob ('specify the path/{0, 1, 2, 3, 4, 5, 6, 8, 9} */*. * ', GLOB_BRACE); echo count ($ );


File structure:

Assume that your program file is at the same level as the dat Directory

$path = 'dat/*/*/3X*/{0,1,2,3,4,5,6,7,8,9}*/*.*';$a = glob($path, GLOB_BRACE);echo count($a);

You can print the result array $.


Assume that your program file is at the same level as the dat Directory

$path = 'dat/*/*/3X*/{0,1,2,3,4,5,6,7,8,9}*/*.*';$a = glob($path, GLOB_BRACE);echo count($a);

You can print the result array $.


What if ftp is used for access?

Assume that your program file is at the same level as the dat Directory

$path = 'dat/*/*/3X*/{0,1,2,3,4,5,6,7,8,9}*/*.*';$a = glob($path, GLOB_BRACE);echo count($a);

You can print the result array $.



Local access is indeed acceptable. what if it is in the form of \ 192.168 \ e \ dat? How to access it? Can I change to ftp?

Must I use php?
It is easy to use the linunx command.

Find folder-type f | wc-l


Assume that your program file is at the same level as the dat Directory

$path = 'dat/*/*/3X*/{0,1,2,3,4,5,6,7,8,9}*/*.*';$a = glob($path, GLOB_BRACE);echo count($a);

You can print the result array $.



Local access is indeed acceptable. what if it is in the form of \ 192.168 \ e \ dat? How to access it? Can I change to ftp?



You need to connect to ftp before executing glob

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.