Untitled
unknown
plain_text
2 years ago
1.7 kB
3
Indexable
import win32file import win32api import win32con import time import os import shutil def scanUSB()-> list: # Tüm aygıt yollarını listeleyen bir dizin oluşturun device_paths = [] # Sürücüleri listeleyin drives = win32api.GetLogicalDriveStrings() # Sürücüleri ayıklayın drives = drives.split('\000')[:-1] # Sürücüleri tarayın for drive in drives: # Sürücü türünü alın drive_type = win32file.GetDriveType(drive) # Eğer sürücü bir USB cihazıysa if drive_type == win32con.DRIVE_REMOVABLE: # Aygıt yolunu diziye ekleyin device_paths.append(drive) if device_paths: return device_paths else: return [] def copyDevices(device): # source_path = 'F:\\' # Dosyaları kopyalamak istediğiniz hedef konumu belirtin target_path = 'C:\\Users\\user\\Documents\\usb_copy\\' # USB cihazındaki tüm dosyaları tarayın for root, dirs, files in os.walk(device): # Her dosya için for file in files: # Dosyanın tam yolunu belirleyin source_file = os.path.join(root, file) # Dosyayı hedef konuma kopyalayın shutil.copy(source_file, target_path) print("USB cihazındaki tüm dosyalar kopyalandı.") return False loop = True while True: if loop: device_paths = scanUSB() # Aygıt yollarını yazdırın for device in device_paths: print(device) loop = copyDevices(device) print("chechk again") time.sleep(1)
Editor is loading...