2

I have 2 python scripts

  1. the first detect the last insert USB drive.
  2. the second is to perform a backup of the folders and files from a USB drive .

detectusb.py

import win32api
import win32file

# Returns a list containing letters from removable drives
drive_list = win32api.GetLogicalDriveStrings()
drive_list = drive_list.split("\x00")[0:-1]  # the last element is ""

for letter in drive_list:
    if win32file.GetDriveType(letter) == win32file.DRIVE_REMOVABLE:# check if the drive is of type removable 

print("list drives: {0}".format(letter))

What i want is to combine these t scripts and run the first script once the user insert the USB i don't know if the cron will do the job but i need to run the script like autorun.

Dev Dj
  • 169
  • 2
  • 14
  • Does this answer your question? [How to run Python script on USB flash-drive insertion](https://stackoverflow.com/questions/44897023/how-to-run-python-script-on-usb-flash-drive-insertion) – Nathan Feb 02 '20 at 12:08
  • i am using the script on windows machine so i don't think this work for me – Dev Dj Feb 02 '20 at 12:14

0 Answers0