Hướng dẫn how do you read all files in a directory and subfolders in python? - làm thế nào để bạn đọc tất cả các tệp trong một thư mục và các thư mục con trong python?

Tôi đang cố gắng dịch dòng bash này bằng Python:

find /usr/share/applications/ -name "*.desktop" -exec grep -il "player" {} \; | sort | while IFS=$'\n' read APPLI ; do grep -ilqw "video" "$APPLI" && echo "$APPLI" ; done | while IFS=$'\n' read APPLI ; do grep -iql "nodisplay=true" "$APPLI" || echo "$[basename "${APPLI%.*}"]" ; done

Kết quả là hiển thị tất cả các ứng dụng video được cài đặt trong hệ thống Ubuntu.

-> Đọc tất cả các tệp .desktop trong/usr/share/Ứng dụng/thư mục

-> Lọc chuỗi "video" "người chơi" để tìm các ứng dụng video

-> Lọc chuỗi "Nodisplay = true" và "Audio" để không hiển thị trình phát âm thanh và ứng dụng NO-GUI

Kết quả tôi muốn có là [ví dụ]:

kmplayer
smplayer
vlc
xbmc

Vì vậy, tôi đã thử mã này:

import os
import fnmatch

apps = []
for root, dirnames, filenames in os.walk['/usr/share/applications/']:
   for dirname in dirnames:
     for filename in filenames:
        with open['/usr/share/applications/' + dirname + "/" + filename, "r"] as auto:
            a = auto.read[50000]
            if "Player" in a or "Video" in a or "video" in a or "player" in a:
              if "NoDisplay=true" not in a or "audio" not in a:
                  print "OK: ", filename
                  filename = filename.replace[".desktop", ""]
                  apps.append[filename]

print apps

Nhưng tôi có vấn đề với các tệp đệ quy ...

Làm thế nào tôi có thể sửa chữa nó? Cảm ơn

Nội dung

  • Giới thiệu
  • Ví dụ 1: Nhận danh sách tất cả các tệp
  • Ví dụ 2: Lấy danh sách tất cả các tệp với một tiện ích mở rộng cụ thể
  • Bản tóm tắt

Để có được danh sách tất cả các tệp trong một thư mục/thư mục và các trình chỉnh sửa/thư mục con của nó, chúng tôi sẽ sử dụng hàm os.walk []. Hàm os.walk [] mang lại một trình lặp qua thư mục hiện tại, trình phụ phụ và tệp của nó.

Trong hướng dẫn này, chúng tôi sẽ trải qua một số ví dụ, trình bày cách lấy danh sách tất cả các tệp trong một thư mục và các thư mục phụ của nó.

Ví dụ 1: Nhận danh sách tất cả các tệp

Ví dụ 2: Lấy danh sách tất cả các tệp với một tiện ích mở rộng cụ thể

Bản tóm tắt

import os

path ="C:/workspace/python"
#we shall store all the file names in this list
filelist = []

for root, dirs, files in os.walk[path]:
	for file in files:
        #append the file name to the list
		filelist.append[os.path.join[root,file]]

#print all the file names
for name in filelist:
    print[name]

Để có được danh sách tất cả các tệp trong một thư mục/thư mục và các trình chỉnh sửa/thư mục con của nó, chúng tôi sẽ sử dụng hàm os.walk []. Hàm os.walk [] mang lại một trình lặp qua thư mục hiện tại, trình phụ phụ và tệp của nó.

Trong hướng dẫn này, chúng tôi sẽ trải qua một số ví dụ, trình bày cách lấy danh sách tất cả các tệp trong một thư mục và các thư mục phụ của nó.

C:\pythonexamples\python-create-directory.png
C:\pythonexamples\python-remove-file.png
C:\pythonexamples\scatter-plot-example.py
C:\pythonexamples\tkinter-example.py
C:\pythonexamples\sample\example.py
C:\pythonexamples\sample\example1.py

Ví dụ 2: Lấy danh sách tất cả các tệp với một tiện ích mở rộng cụ thể

Bản tóm tắt.py here, in the directory and its sub-directories recursively.

Bản tóm tắt

import os

path ="C:\workspace\python"

for root, dirs, files in os.walk[path]:
	for file in files:
		if[file.endswith[".py"]]:
			print[os.path.join[root,file]]

Trong hướng dẫn này, chúng tôi sẽ trải qua một số ví dụ, trình bày cách lấy danh sách tất cả các tệp trong một thư mục và các thư mục phụ của nó.

C:\pythonexamples\scatter-plot-example.py
C:\pythonexamples\tkinter-example.py
C:\pythonexamples\sample\example.py
C:\pythonexamples\sample\example1.py

Bản tóm tắt

Để có được danh sách tất cả các tệp trong một thư mục/thư mục và các trình chỉnh sửa/thư mục con của nó, chúng tôi sẽ sử dụng hàm os.walk []. Hàm os.walk [] mang lại một trình lặp qua thư mục hiện tại, trình phụ phụ và tệp của nó.

Trong bài viết này, chúng ta sẽ thấy cách liệt kê tất cả các tệp của một thư mục trong Python. Có nhiều cách để liệt kê các tập tin của một thư mục. Trong bài viết này, chúng tôi sẽ sử dụng các phương thức sau & nbsp; bốn phương thức.four methods.

  • import os
    import fnmatch
    
    apps = []
    for root, dirnames, filenames in os.walk['/usr/share/applications/']:
       for dirname in dirnames:
         for filename in filenames:
            with open['/usr/share/applications/' + dirname + "/" + filename, "r"] as auto:
                a = auto.read[50000]
                if "Player" in a or "Video" in a or "video" in a or "player" in a:
                  if "NoDisplay=true" not in a or "audio" not in a:
                      print "OK: ", filename
                      filename = filename.replace[".desktop", ""]
                      apps.append[filename]
    
    print apps
    
    3: Trả về danh sách các tệp và thư mục có trong một đường dẫn thư mục được chỉ định.
  • import os
    import fnmatch
    
    apps = []
    for root, dirnames, filenames in os.walk['/usr/share/applications/']:
       for dirname in dirnames:
         for filename in filenames:
            with open['/usr/share/applications/' + dirname + "/" + filename, "r"] as auto:
                a = auto.read[50000]
                if "Player" in a or "Video" in a or "video" in a or "player" in a:
                  if "NoDisplay=true" not in a or "audio" not in a:
                      print "OK: ", filename
                      filename = filename.replace[".desktop", ""]
                      apps.append[filename]
    
    print apps
    
    4: Tập hợp lại danh sách tất cả các tệp trong thư mục và thư mục con.
  • import os
    import fnmatch
    
    apps = []
    for root, dirnames, filenames in os.walk['/usr/share/applications/']:
       for dirname in dirnames:
         for filename in filenames:
            with open['/usr/share/applications/' + dirname + "/" + filename, "r"] as auto:
                a = auto.read[50000]
                if "Player" in a or "Video" in a or "video" in a or "player" in a:
                  if "NoDisplay=true" not in a or "audio" not in a:
                      print "OK: ", filename
                      filename = filename.replace[".desktop", ""]
                      apps.append[filename]
    
    print apps
    
    5: Trả về các mục nhập thư mục cùng với thông tin thuộc tính tệp.
  • import os
    import fnmatch
    
    apps = []
    for root, dirnames, filenames in os.walk['/usr/share/applications/']:
       for dirname in dirnames:
         for filename in filenames:
            with open['/usr/share/applications/' + dirname + "/" + filename, "r"] as auto:
                a = auto.read[50000]
                if "Player" in a or "Video" in a or "video" in a or "player" in a:
                  if "NoDisplay=true" not in a or "audio" not in a:
                      print "OK: ", filename
                      filename = filename.replace[".desktop", ""]
                      apps.append[filename]
    
    print apps
    
    6: Mô -đun GLOB đến & NBSP; Liệt kê các tệp và thư mục có tên theo một mẫu cụ thể.

Cách liệt kê tất cả các tệp của một thư mục

Nhận một danh sách các tập tin của một thư mục rất dễ dàng như PIE! Sử dụng các hàm

import os
import fnmatch

apps = []
for root, dirnames, filenames in os.walk['/usr/share/applications/']:
   for dirname in dirnames:
     for filename in filenames:
        with open['/usr/share/applications/' + dirname + "/" + filename, "r"] as auto:
            a = auto.read[50000]
            if "Player" in a or "Video" in a or "video" in a or "player" in a:
              if "NoDisplay=true" not in a or "audio" not in a:
                  print "OK: ", filename
                  filename = filename.replace[".desktop", ""]
                  apps.append[filename]

print apps
7 và
import os
import fnmatch

apps = []
for root, dirnames, filenames in os.walk['/usr/share/applications/']:
   for dirname in dirnames:
     for filename in filenames:
        with open['/usr/share/applications/' + dirname + "/" + filename, "r"] as auto:
            a = auto.read[50000]
            if "Player" in a or "Video" in a or "video" in a or "player" in a:
              if "NoDisplay=true" not in a or "audio" not in a:
                  print "OK: ", filename
                  filename = filename.replace[".desktop", ""]
                  apps.append[filename]

print apps
8 của mô -đun HĐH để liệt kê tất cả các tệp của thư mục. Đây là các bước.
import os
import fnmatch

apps = []
for root, dirnames, filenames in os.walk['/usr/share/applications/']:
   for dirname in dirnames:
     for filename in filenames:
        with open['/usr/share/applications/' + dirname + "/" + filename, "r"] as auto:
            a = auto.read[50000]
            if "Player" in a or "Video" in a or "video" in a or "player" in a:
              if "NoDisplay=true" not in a or "audio" not in a:
                  print "OK: ", filename
                  filename = filename.replace[".desktop", ""]
                  apps.append[filename]

print apps
7 and
import os
import fnmatch

apps = []
for root, dirnames, filenames in os.walk['/usr/share/applications/']:
   for dirname in dirnames:
     for filename in filenames:
        with open['/usr/share/applications/' + dirname + "/" + filename, "r"] as auto:
            a = auto.read[50000]
            if "Player" in a or "Video" in a or "video" in a or "player" in a:
              if "NoDisplay=true" not in a or "audio" not in a:
                  print "OK: ", filename
                  filename = filename.replace[".desktop", ""]
                  apps.append[filename]

print apps
8 functions
of an os module to list all files of a directory. Here are the steps.

  1. Nhập mô -đun hệ điều hành

    Mô-đun này giúp chúng tôi làm việc với chức năng phụ thuộc hệ điều hành trong Python. Mô -đun OS cung cấp các chức năng để tương tác với hệ điều hành.

  2. Sử dụng hàm Os.ListDir []

    Hàm

    import os
    import fnmatch
    
    apps = []
    for root, dirnames, filenames in os.walk['/usr/share/applications/']:
       for dirname in dirnames:
         for filename in filenames:
            with open['/usr/share/applications/' + dirname + "/" + filename, "r"] as auto:
                a = auto.read[50000]
                if "Player" in a or "Video" in a or "video" in a or "player" in a:
                  if "NoDisplay=true" not in a or "audio" not in a:
                      print "OK: ", filename
                      filename = filename.replace[".desktop", ""]
                      apps.append[filename]
    
    print apps
    
    9 trả về một danh sách chứa tên của các tệp và thư mục có trong thư mục được đưa ra bởi
    import os
    
    path ="C:/workspace/python"
    #we shall store all the file names in this list
    filelist = []
    
    for root, dirs, files in os.walk[path]:
    	for file in files:
            #append the file name to the list
    		filelist.append[os.path.join[root,file]]
    
    #print all the file names
    for name in filelist:
        print[name]
    0.

  3. Lặp lại kết quả

    Sử dụng cho vòng lặp để lặp lại các tệp được trả về bởi hàm listDIR []. Sử dụng cho vòng lặp, chúng tôi sẽ lặp lại mỗi tệp được trả về bởi

    import os
    
    path ="C:/workspace/python"
    #we shall store all the file names in this list
    filelist = []
    
    for root, dirs, files in os.walk[path]:
    	for file in files:
            #append the file name to the list
    		filelist.append[os.path.join[root,file]]
    
    #print all the file names
    for name in filelist:
        print[name]
    1Function

  4. Sử dụng hàm isfile []

    Trong mỗi lần lặp vòng lặp, sử dụng hàm

    import os
    
    path ="C:/workspace/python"
    #we shall store all the file names in this list
    filelist = []
    
    for root, dirs, files in os.walk[path]:
    	for file in files:
            #append the file name to the list
    		filelist.append[os.path.join[root,file]]
    
    #print all the file names
    for name in filelist:
        print[name]
    2 để kiểm tra xem đường dẫn hiện tại có phải là tệp hoặc thư mục hay không. Nếu đó là một tập tin, sau đó thêm nó vào một danh sách. Hàm này trả về true nếu một đường dẫn nhất định là một tệp. Nếu không, nó trả về sai.

Ví dụ để liệt kê các tệp của một thư mục

Hãy để xem cách liệt kê các tệp của một thư mục tài khoản.

import os
import fnmatch

apps = []
for root, dirnames, filenames in os.walk['/usr/share/applications/']:
   for dirname in dirnames:
     for filename in filenames:
        with open['/usr/share/applications/' + dirname + "/" + filename, "r"] as auto:
            a = auto.read[50000]
            if "Player" in a or "Video" in a or "video" in a or "player" in a:
              if "NoDisplay=true" not in a or "audio" not in a:
                  print "OK: ", filename
                  filename = filename.replace[".desktop", ""]
                  apps.append[filename]

print apps
7 sẽ chỉ liệt kê các tệp trong thư mục hiện tại và bỏ qua các thư mục con.list files only in the current directory and ignore the subdirectories.

Ví dụ 1: Chỉ liệt kê các tệp từ thư mục: List only files from a directory

import os

# folder path
dir_path = r'E:\\account\\'

# list to store files
res = []

# Iterate directory
for path in os.listdir[dir_path]:
    # check if current path is a file
    if os.path.isfile[os.path.join[dir_path, path]]:
        res.append[path]
print[res]

Output::

Ở đây chúng tôi có ba tên tập tin.

['profit.txt', 'sales.txt', 'sample.txt']

Nếu bạn biết biểu thức máy phát, bạn có thể làm cho mã nhỏ hơn và đơn giản bằng cách sử dụng hàm máy phát như hình bên dưới.

Biểu thức của máy phát::

import os

def get_files[path]:
    for file in os.listdir[path]:
        if os.path.isfile[os.path.join[path, file]]:
            yield file

Sau đó, chỉ cần gọi nó bất cứ khi nào cần thiết.

kmplayer
smplayer
vlc
xbmc
0

Ví dụ 2: Liệt kê cả tệp và thư mục.: List both files and directories.

Trực tiếp gọi chức năng

import os

path ="C:/workspace/python"
#we shall store all the file names in this list
filelist = []

for root, dirs, files in os.walk[path]:
	for file in files:
        #append the file name to the list
		filelist.append[os.path.join[root,file]]

#print all the file names
for name in filelist:
    print[name]
4 để có được nội dung của một thư mục.

kmplayer
smplayer
vlc
xbmc
1

Output::

Như bạn có thể thấy trong đầu ra, ‘Báo cáo_2021 là một thư mục.

kmplayer
smplayer
vlc
xbmc
2

import os

path ="C:/workspace/python"
#we shall store all the file names in this list
filelist = []

for root, dirs, files in os.walk[path]:
	for file in files:
        #append the file name to the list
		filelist.append[os.path.join[root,file]]

#print all the file names
for name in filelist:
    print[name]
5 để liệt kê tất cả các tệp trong thư mục và thư mục con

Hàm os.walk [] trả về một trình tạo tạo một bộ giá trị [current_path, thư mục trong current_path, file in current_path].

Lưu ý: Sử dụng chức năng

import os

path ="C:/workspace/python"
#we shall store all the file names in this list
filelist = []

for root, dirs, files in os.walk[path]:
	for file in files:
        #append the file name to the list
		filelist.append[os.path.join[root,file]]

#print all the file names
for name in filelist:
    print[name]
5, chúng tôi có thể liệt kê tất cả các thư mục, thư mục con và tệp trong một thư mục nhất định.: Using the
import os

path ="C:/workspace/python"
#we shall store all the file names in this list
filelist = []

for root, dirs, files in os.walk[path]:
	for file in files:
        #append the file name to the list
		filelist.append[os.path.join[root,file]]

#print all the file names
for name in filelist:
    print[name]
5 function we can list all directories, subdirectories, and files in a given directory.

Đó là một hàm đệ quy, tức là mỗi khi trình tạo được gọi, nó sẽ theo từng thư mục đệ quy để có được danh sách các tệp và thư mục cho đến khi không có các thư mục phụ nào có sẵn từ thư mục ban đầu.recursive function, i.e., every time the generator is called, it will follow each directory recursively to get a list of files and directories until no further sub-directories are available from the initial directory.

Ví dụ: gọi

import os

path ="C:/workspace/python"
#we shall store all the file names in this list
filelist = []

for root, dirs, files in os.walk[path]:
	for file in files:
        #append the file name to the list
		filelist.append[os.path.join[root,file]]

#print all the file names
for name in filelist:
    print[name]
7 sẽ mang lại hai danh sách cho mỗi thư mục mà nó truy cập. Danh sách đầu tiên chứa các tập tin và danh sách thứ hai bao gồm các thư mục.

Hãy cùng xem ví dụ để liệt kê tất cả các tệp trong thư mục và thư mục con.

Example::

kmplayer
smplayer
vlc
xbmc
3

Output::

kmplayer
smplayer
vlc
xbmc
4

Lưu ý: Thêm Break Inside một vòng lặp để ngừng tìm kiếm các tệp đệ quy bên trong các thư mục con.: Add break inside a loop to stop looking for files recursively inside subdirectories.

Example::

kmplayer
smplayer
vlc
xbmc
5

import os

path ="C:/workspace/python"
#we shall store all the file names in this list
filelist = []

for root, dirs, files in os.walk[path]:
	for file in files:
        #append the file name to the list
		filelist.append[os.path.join[root,file]]

#print all the file names
for name in filelist:
    print[name]
8 để lấy các tệp của một thư mục

Hàm

import os

path ="C:/workspace/python"
#we shall store all the file names in this list
filelist = []

for root, dirs, files in os.walk[path]:
	for file in files:
        #append the file name to the list
		filelist.append[os.path.join[root,file]]

#print all the file names
for name in filelist:
    print[name]
9 trả về các mục nhập thư mục cùng với thông tin thuộc tính tệp, mang lại hiệu suất tốt hơn cho nhiều trường hợp sử dụng phổ biến.

Nó trả về một trình lặp của các đối tượng

C:\pythonexamples\python-create-directory.png
C:\pythonexamples\python-remove-file.png
C:\pythonexamples\scatter-plot-example.py
C:\pythonexamples\tkinter-example.py
C:\pythonexamples\sample\example.py
C:\pythonexamples\sample\example1.py
0, chứa tên tệp.

Example::

kmplayer
smplayer
vlc
xbmc
6

Output::

kmplayer
smplayer
vlc
xbmc
7

Mô -đun toàn cầu để liệt kê các tệp của một thư mục

Mô -đun Glob Python, một phần của thư viện tiêu chuẩn Python, được sử dụng để & nbsp; tìm các tệp và thư mục có tên theo một mẫu cụ thể.find the files and folders whose names follow a specific pattern.

Ví dụ: để có được tất cả các tệp của một thư mục, chúng tôi sẽ sử dụng mẫu

C:\pythonexamples\python-create-directory.png
C:\pythonexamples\python-remove-file.png
C:\pythonexamples\scatter-plot-example.py
C:\pythonexamples\tkinter-example.py
C:\pythonexamples\sample\example.py
C:\pythonexamples\sample\example1.py
1. Ở đây,
C:\pythonexamples\python-create-directory.png
C:\pythonexamples\python-remove-file.png
C:\pythonexamples\scatter-plot-example.py
C:\pythonexamples\tkinter-example.py
C:\pythonexamples\sample\example.py
C:\pythonexamples\sample\example1.py
2 có nghĩa là tệp với bất kỳ tiện ích mở rộng nào.

Đọc thêm: Các tệp danh sách Python trong một thư mục với TXT mở rộng.: Python list files in a directory with extension txt.

Hãy để xem cách liệt kê các tệp từ một thư mục bằng mô -đun GLOB.

Example::

kmplayer
smplayer
vlc
xbmc
8

Output::

kmplayer
smplayer
vlc
xbmc
9

Lưu ý: Nếu bạn muốn liệt kê các tệp từ các thư mục con, thì hãy đặt thuộc tính

C:\pythonexamples\python-create-directory.png
C:\pythonexamples\python-remove-file.png
C:\pythonexamples\scatter-plot-example.py
C:\pythonexamples\tkinter-example.py
C:\pythonexamples\sample\example.py
C:\pythonexamples\sample\example1.py
3 thành TRUE.: If you want to list files from subdirectories, then set the
C:\pythonexamples\python-create-directory.png
C:\pythonexamples\python-remove-file.png
C:\pythonexamples\scatter-plot-example.py
C:\pythonexamples\tkinter-example.py
C:\pythonexamples\sample\example.py
C:\pythonexamples\sample\example1.py
3 attribute to True.

Example::

import os
import fnmatch

apps = []
for root, dirnames, filenames in os.walk['/usr/share/applications/']:
   for dirname in dirnames:
     for filename in filenames:
        with open['/usr/share/applications/' + dirname + "/" + filename, "r"] as auto:
            a = auto.read[50000]
            if "Player" in a or "Video" in a or "video" in a or "player" in a:
              if "NoDisplay=true" not in a or "audio" not in a:
                  print "OK: ", filename
                  filename = filename.replace[".desktop", ""]
                  apps.append[filename]

print apps
0

Output::

import os
import fnmatch

apps = []
for root, dirnames, filenames in os.walk['/usr/share/applications/']:
   for dirname in dirnames:
     for filename in filenames:
        with open['/usr/share/applications/' + dirname + "/" + filename, "r"] as auto:
            a = auto.read[50000]
            if "Player" in a or "Video" in a or "video" in a or "player" in a:
              if "NoDisplay=true" not in a or "audio" not in a:
                  print "OK: ", filename
                  filename = filename.replace[".desktop", ""]
                  apps.append[filename]

print apps
1

Mô -đun Pathlib để liệt kê các tệp của một thư mục

Từ Python 3.4 trở đi, chúng ta có thể sử dụng mô -đun & nbsp; pathlib, cung cấp trình bao bọc cho hầu hết các chức năng HĐH.

  • Nhập mô -đun Pathlib: Mô -đun PathLib cung cấp các lớp và phương thức để xử lý các đường dẫn hệ thống tệp và nhận dữ liệu liên quan đến các tệp cho các hệ điều hành khác nhau.
  • Tiếp theo, sử dụng & nbsp; ________ 44 để xây dựng đường dẫn thư mục
  • Tiếp theo, sử dụng
    C:\pythonexamples\python-create-directory.png
    C:\pythonexamples\python-remove-file.png
    C:\pythonexamples\scatter-plot-example.py
    C:\pythonexamples\tkinter-example.py
    C:\pythonexamples\sample\example.py
    C:\pythonexamples\sample\example1.py
    5 để lặp lại tất cả các mục của thư mục
  • Cuối cùng, kiểm tra xem mục nhập hiện tại có phải là tệp sử dụng hàm
    C:\pythonexamples\python-create-directory.png
    C:\pythonexamples\python-remove-file.png
    C:\pythonexamples\scatter-plot-example.py
    C:\pythonexamples\tkinter-example.py
    C:\pythonexamples\sample\example.py
    C:\pythonexamples\sample\example1.py
    6 không

Example::

import os
import fnmatch

apps = []
for root, dirnames, filenames in os.walk['/usr/share/applications/']:
   for dirname in dirnames:
     for filename in filenames:
        with open['/usr/share/applications/' + dirname + "/" + filename, "r"] as auto:
            a = auto.read[50000]
            if "Player" in a or "Video" in a or "video" in a or "player" in a:
              if "NoDisplay=true" not in a or "audio" not in a:
                  print "OK: ", filename
                  filename = filename.replace[".desktop", ""]
                  apps.append[filename]

print apps
2

Làm thế nào tôi có thể nhận được một danh sách tất cả các tệp trong một thư mục và các thư mục con của nó?

Mở tệp Explorer trong Windows.....
Nhấp vào thanh địa chỉ và thay thế đường dẫn tệp bằng cách nhập CMD sau đó nhấn Enter ..
Điều này sẽ mở một lời nhắc lệnh màu đen và trắng hiển thị đường dẫn tệp trên ..
Loại dir /a: d.....
Bây giờ nên có một tệp văn bản mới gọi là danh sách thư mục trong thư mục trên ..

Làm thế nào tôi có thể nhận được một danh sách tất cả các thư mục con và tệp có trong một thư mục bằng PHP?

PHP sử dụng scandir [] để tìm các thư mục trong thư mục hàm scandir là một hàm sẵn có trả về một loạt các tệp và thư mục của một thư mục cụ thể.Nó liệt kê các tệp và thư mục có bên trong đường dẫn được chỉ định bởi người dùng.scandir[] to find folders in a directory The scandir function is an inbuilt function that returns an array of files and directories of a specific directory. It lists the files and directories present inside the path specified by the user.

Bài Viết Liên Quan

Chủ Đề