You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
995 B
23 lines
995 B
1 year ago
|
import os
|
||
|
|
||
|
def generate_file_list(directory, output_file):
|
||
|
"""
|
||
|
Generate a list of files in a directory in the specified format and write it to a file.
|
||
|
|
||
|
Args:
|
||
|
directory (str): The directory to list the files from.
|
||
|
output_file (str): The file to write the output to.
|
||
|
"""
|
||
|
with open(output_file, 'w') as f:
|
||
|
for root, dirs, files in os.walk(directory):
|
||
|
for file in files:
|
||
|
if file.endswith('.md'):
|
||
|
# Remove the directory from the file path and replace slashes with dots
|
||
|
file_path = os.path.join(root, file).replace(directory + '/', '').replace('/', '.')
|
||
|
# Remove the file extension
|
||
|
file_name, _ = os.path.splitext(file)
|
||
|
# Write the file name and path to the output file
|
||
|
f.write(f"- {file_name}: \"{file_path}\"\n")
|
||
|
|
||
|
# Use the function to generate the file list
|
||
|
generate_file_list('docs/swarms/utils', 'file_list.txt')
|