bsc

Comprehensive codebase and cou...
Log | Files | Refs | README | LICENSE

list.py (1644B)


      1 import os
      2 
      3 EXTENSIONS = ('.c', '.r', '.cpp', '.py')
      4 
      5 EXCLUDE = ('list.py', 'md.py', 'utils', 'docs') 
      6 
      7 ALGO_FOLDER_NAME = 'algorithms'  
      8 
      9 def list_all_files(start_path='.', output_file='list.txt'):
     10     try:
     11         count = 0
     12         with open(output_file, 'w', encoding='utf-8') as f:
     13             for root, dirs, files in os.walk(start_path):
     14                 dirs[:] = [d for d in dirs if d not in EXCLUDE]
     15 
     16                 in_algo_folder = os.path.basename(root).lower() == ALGO_FOLDER_NAME
     17 
     18                 for file in files:
     19                     if file in EXCLUDE:
     20                         continue
     21                     if file.lower().endswith(EXTENSIONS):
     22                         full_path = os.path.abspath(os.path.join(root, file))
     23                         f.write(full_path + '\n')
     24                         count += 1
     25                     elif in_algo_folder and file.lower().endswith('.md'):
     26                         full_path = os.path.abspath(os.path.join(root, file))
     27                         f.write(full_path + '\n')
     28                         count += 1
     29 
     30         print(f"\nSuccessfully found {count} file(s).")
     31         print(f"Results have been saved to: {os.path.abspath(output_file)}")
     32 
     33     except PermissionError:
     34         print("Error: Permission denied in some directories.")
     35     except Exception as e:
     36         print(f"An unexpected error occurred: {e}")
     37 
     38 if __name__ == "__main__":
     39     current_directory = os.getcwd()
     40 
     41     print(f"Scanning for {', '.join(EXTENSIONS)} files and algorithm .md files in: {current_directory}\n")
     42     print("-" * 30)
     43 
     44     list_all_files(current_directory)
     45 
     46     print("-" * 30)
     47     print("Scan complete.")
© notamitgamer • Site Built: 2026-07-21 13:58:23 UTC • git-mirror commit: 1037f62 [view raw info]
Originally created with stagit • modified by notamitgamer
Forked from github.com/notamitgamer/git-mirror