Ben Log İle Uğraştığım İçin Bazen İşime Yarıyor.
Telegram Gruplarındaki Logları İndirip İçindeki TXT,PASSWORD VB Şeyleri Alıp Tek Klasör Veya Tek TXT Haline Getirebilirsiniz.
Passwords dosyalarını tek klasöre taşıma Python Kodu
Bütün TXT dosyalarını tek klasöre taşıma Python Kodu
+1 Artırarak Bütün TXT dosyalarını tek klasöre taşıma Python Kodu
TXT Dosya Birleştirme
Telegram Gruplarındaki Logları İndirip İçindeki TXT,PASSWORD VB Şeyleri Alıp Tek Klasör Veya Tek TXT Haline Getirebilirsiniz.
Passwords dosyalarını tek klasöre taşıma Python Kodu
Kod:
import os
import shutil
def copy_password_files(source_folder, destination_folder):
# Yeni klasörü oluştur (varsa geçersiz kıl)
os.makedirs(destination_folder, exist_ok=True)
# Sayacı başlat
count = 1
# Kaynak klasördeki tüm dosya ve klasörleri dolaş
for root, dirs, files in os.walk(source_folder):
# Her bir dosya için kontrol et
for file in files:
# Sadece passwords.txt dosyalarını kopyala
if file == "Passwords.txt":
# Dosyanın tam yolunu oluştur
file_path = os.path.join(root, file)
# Hedef dosya adını oluştur
destination_filename = f"passwords{count}.txt"
destination_path = os.path.join(destination_folder, destination_filename)
# Dosyayı hedef klasöre kopyala
shutil.copy(file_path, destination_path)
print(f"{file_path} kopyalandı. Yeni isim: {destination_filename}")
# Sayacı artır
count += 1
# Klasörleri ve yolunu belirt
source_folder = r"BURAYA KLASÖR YOLUNU YAZ" # Kaynak klasörün yolu
destination_folder = r"BURAYA HEDEF KLASÖR YOLUNU YAZ" # Hedef klasörün yolu
# Fonksiyonu çağır
copy_password_files(source_folder, destination_folder)
Bütün TXT dosyalarını tek klasöre taşıma Python Kodu
Kod:
import os
import shutil
def copy_text_files(source_folder, destination_folder):
# Create the new folder (overwrite if it exists)
os.makedirs(destination_folder, exist_ok=True)
# Initialize counter
count = 1
# Traverse all files and folders in the source folder
for root, dirs, files in os.walk(source_folder):
# Check each file
for file in files:
# Only copy .txt files
if file.endswith(".txt"):
# Create the full file path
file_path = os.path.join(root, file)
# Create the destination file name
destination_filename = f"text{count}.txt"
destination_path = os.path.join(destination_folder, destination_filename)
# Copy the file to the destination folder
shutil.copy(file_path, destination_path)
print(f"{file_path} copied. New name: {destination_filename}")
# Increment counter
count += 1
# Specify the folders and paths
source_folder = r"BURAYA KLASÖR YOLUNU YAZ" # Path to source folder
destination_folder = r"BURAYA HEDEF KLASÖR YOLUNU YAZ" # Path to destination folder
# Call the function
copy_text_files(source_folder, destination_folder)
+1 Artırarak Bütün TXT dosyalarını tek klasöre taşıma Python Kodu
Kod:
import os
import shutil
def copy_text_files(source_folder, destination_folder):
# Create the new folder (overwrite if it exists)
os.makedirs(destination_folder, exist_ok=True)
# Initialize counter
count = 1
# Traverse all files and folders in the source folder
for root, dirs, files in os.walk(source_folder):
# Check each file
for file in files:
# Only copy .txt files
if file.endswith(".txt"):
# Create the full file path
file_path = os.path.join(root, file)
# Extract the file name and extension
file_name, file_ext = os.path.splitext(file)
# Create the destination file name
destination_filename = f"{file_name}{count}{file_ext}"
destination_path = os.path.join(destination_folder, destination_filename)
# Copy the file to the destination folder
shutil.copy(file_path, destination_path)
print(f"{file_path} copied. New name: {destination_filename}")
# Increment counter
count += 1
# Specify the folders and paths
source_folder = r"BURAYA KLASÖR YOLUNU YAZ" # Path to source folder
destination_folder = r"BURAYA HEDEF KLASÖR YOLUNU YAZ" # Path to destination folder
# Call the function
copy_text_files(source_folder, destination_folder)
TXT Dosya Birleştirme
Kod:
import os
# Klasör yolunu belirtin
klasor_yolu = r"BURAYA KLASÖR YOLUNU YAZ"
# Yeni dosya adını ve yolunu belirtin
yeni_dosya_yolu = r"BURAYA HEDEF DOSYA YOLUNU VE ADINI YAZ"
# Klasördeki tüm dosyaları al
dosyalar = os.listdir(klasor_yolu)
# Yeni dosyayı oluştur ve yazma modunda aç
with open(yeni_dosya_yolu, 'w', encoding='utf-8') as yeni_dosya:
# Klasördeki her dosya için
for dosya in dosyalar:
# Dosya .txt uzantılı ise
if dosya.endswith('.txt'):
# Dosyanın tam yolunu oluştur
dosya_yolu = os.path.join(klasor_yolu, dosya)
# Dosyayı okuma modunda aç
with open(dosya_yolu, 'r', encoding='utf-8') as mevcut_dosya:
# Dosya içeriğini oku
icerik = mevcut_dosya.read()
# İçeriği yeni dosyaya yaz
yeni_dosya.write(icerik)
# İçerikler arasında bir satır boşluk bırak
yeni_dosya.write('\n')