File size: 582 Bytes
090987a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import os
import csv

# Path to the folder you want to scan
folder_path = 'people'

# Get all subfolder names
subfolders = [f.name for f in os.scandir(folder_path) if f.is_dir()]

# Path to the output CSV file
csv_file = 'subfolders.csv'

# Write the subfolder names to the CSV file
with open(csv_file, mode='w', newline='') as file:
    writer = csv.writer(file)
    writer.writerow(['Subfolder Name'])  # Write the header
    for subfolder in subfolders:
        writer.writerow([subfolder])  # Write each subfolder name

print(f"Subfolder names have been written to {csv_file}")