How to run something when a USB drive is plugged in
Use KeyRoutines' Device connected trigger with your drive's name, a Wait until with File or folder exists for its drive letter, then Format date, Create folder and Move or copy file in copy mode to back up a folder onto it. Show banner tells you when it's safe to unplug.
Steps
- 1
Watch for the drive
Add Device connected and type part of the drive's name as Windows shows it, such as SanDisk.
- 2
Wait for the drive letter
Add Wait until with File or folder exists for E:\ and a timeout of 30 seconds.
- 3
Make a dated folder
Add Format date with yyyy-MM-dd and Create folder E:\Backups\date.
- 4
Copy your files
Add Move or copy file in copy mode with your project folder as the source and the dated folder as the destination.
- 5
Say when it's done
Add Show banner "Backup finished, safe to unplug".
Tips
- Give the drive a fixed letter in Disk Management so it always mounts as the same letter.
- Device connected only fires for devices that connect while KeyRoutines runs, not ones already plugged in.
Questions
- Is this the same as Windows AutoPlay?
- AutoPlay offers a choice of a few actions. A routine can do anything with the drive: copy, zip, open apps or sort files.
- Can it run when a specific phone or camera connects?
- Yes, if it shows up as a device in Windows. Use its name in Device connected.