Python İle Basit TXT ve Klasör Düzenleme

burak513165

Uzman üye
29 Tem 2017
1,439
33
VATAN
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

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

Grimner

Adanmış Üye
28 Mar 2020
6,326
4,809
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

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')
Açıklamaların yarısı İngilizce yarısı Türkçe olması garip olmuş.
 
Üst

Turkhackteam.org internet sitesi 5651 sayılı kanun’un 2. maddesinin 1. fıkrasının m) bendi ile aynı kanunun 5. maddesi kapsamında "Yer Sağlayıcı" konumundadır. İçerikler ön onay olmaksızın tamamen kullanıcılar tarafından oluşturulmaktadır. Turkhackteam.org; Yer sağlayıcı olarak, kullanıcılar tarafından oluşturulan içeriği ya da hukuka aykırı paylaşımı kontrol etmekle ya da araştırmakla yükümlü değildir. Türkhackteam saldırı timleri Türk sitelerine hiçbir zararlı faaliyette bulunmaz. Türkhackteam üyelerinin yaptığı bireysel hack faaliyetlerinden Türkhackteam sorumlu değildir. Sitelerinize Türkhackteam ismi kullanılarak hack faaliyetinde bulunulursa, site-sunucu erişim loglarından bu faaliyeti gerçekleştiren ip adresini tespit edip diğer kanıtlarla birlikte savcılığa suç duyurusunda bulununuz.