import os

def count_videos_in_csvs(split_dir='./data/HAC_Splits/'):
    total_videos = 0
    
    print(f"Scanning directory: {split_dir}\n")
    
    if not os.path.exists(split_dir):
        print(f"Error: Directory '{split_dir}' not found. Make sure you run this from your main HAC folder.")
        return

    # Loop through all files in the directory alphabetically
    for filename in sorted(os.listdir(split_dir)):
        if filename.endswith('.csv'):
            filepath = os.path.join(split_dir, filename)
            
            with open(filepath, 'r', encoding='utf-8') as f:
                # Count the number of lines in the file
                line_count = sum(1 for line in f)
                
                # Print the count for each specific file
                print(f"{filename:<30} {line_count} videos")
                
                total_videos += line_count
                
    print("-" * 45)
    print(f"{'Grand Total:':<30} {total_videos} videos")

if __name__ == '__main__':
    count_videos_in_csvs()