File size: 570 Bytes
bd4d522
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import os

def list_directory_structure(startpath):
    for root, dirs, files in os.walk(startpath):
        level = root.replace(startpath, '').count(os.sep)
        indent = ' ' * 4 * level
        print(f"{indent}{os.path.basename(root)}/")
        subindent = ' ' * 4 * (level + 1)
        for f in files:
            if not f.endswith(('.png', '.jpg')):
                print(f"{subindent}{f}")

# 指定需要列出目录结构的根目录路径
root_path = '/mnt/petrelfs/zhuchenglin/LLaVA'  # 例如 '/home/user/my_directory'
list_directory_structure(root_path)