File size: 882 Bytes
057576a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import os

root_path = r"C:/Users/ysnrfd/Desktop/ysnrfd_messenger2/BACKUP4"   # مسیر پوشه اصلی
output_file = "output4.txt"

with open(output_file, "w", encoding="utf-8") as out:
    for folder, subfolders, files in os.walk(root_path):
        for file in files:
            file_path = os.path.join(folder, file)

            # مسیر فایل
            out.write(f"\n=== FILE PATH ===\n{file_path}\n")
            out.write("=== CONTENT ===\n")

            try:
                # فایل‌های خیلی بزرگ رو هم بدون اینکه رم پر بشه می‌خونه
                with open(file_path, "r", encoding="utf-8", errors="ignore") as f:
                    for line in f:
                        out.write(line)
            except Exception as e:
                out.write(f"[خطا در خوندن فایل: {e}]\n")