import os

def find_less_files(folder_path):
    less_files = []
    for root, dirs, files in os.walk(folder_path):
        for file in files:
            if file.endswith('.less'):
                less_files.append(os.path.relpath(os.path.join(root, file), folder_path).replace('\\','/'))
    return less_files

def write_paths_to_file(file_paths, output_file):
    with open(output_file, 'w') as f:
        for path in file_paths:
            f.write(f'@import "{path}";' + '\n')

if __name__ == "__main__":
    folder_path = "sugarcube/src"
    output_file = "sugarcube/src/main.less"
    if os.path.exists(output_file):
        os.remove(output_file)
    
    less_files = find_less_files(folder_path)

    write_paths_to_file(less_files, output_file)
