|
|
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")
|
|
|
|