| 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}") | |